Skip to content

david-lyder/tiff-utility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

Usage

app.exe
Manipulate TIFF image files. Remove page by number, remove blank page, concatenate two TIFF files.
Remove a blank page:
app.exe -remove-blank [TIFF file name] [output TIFF file name]
Remove a page by page number:
app.exe -remove-page [page number] [TIFF file name] [output TIFF file name]
Concatenate two TIFF files:
app.exe -cat [TIFF file name 1] [TIFF file name 2] [output TIFF file name]
Get version info:
app.exe -version
Get help:
app.exe -help

Examples

The repo contains an input folder with suitable TIFF image files.
blank.tif
four_black.tif
four_page.tif
multipage.tif
NOTE: app.exe only supports uncompressed TIFF images.
The utility at: https://online-converting.com/image/convert2tiff/ was used to create uncompressed TIFF images.

To remove a blank page:
app.exe -remove-blank ..\input\multipage.tif blank_removed.tif

To remove a page by number:
app.exe -remove-page 2 ..\input\multipage.tif page_2_removed.tif

To concatenate two files:
app.exe -cat ..\input\four_page.tif ..\input\four_page.tif eight_page.tif

Developer Notes

The tifflib distibution, tiff-4.0.10, is inluded in this repo.
tifflib was built in release mode for Microsoft Visual Studio C++ using nmake:
nmake -f makefile.vc
from the developer command prompt for VS2012

One change was required in tif_config.h. The following code was added:
#if defined(_MSC_VER)
#define strtoll _strtoi64
#endif
app.exe includes a reference to the static library libtiff.lib

Implementation decisions

Removing a page by number from a TIFF was relatively easy by cycling through the directories using TIFFReadDirectory, keeping track of the page count, and skipping TIFFReadScanline-TIFFWriteScanline for the requested page number.

Merging TIFF files was accomplished using a similar technique, cycling through all of the input files and using IFFReadScanline-TIFFWriteScanline for every directory and writing all results to a new file.

Identifying a blank TIFF proved to be difficult (perhaps there is a secret?). This is the method used:
Cycle through the input TIFF and create a new TIFF file for each page
Use the C code from the libtiff tools folder to create a "tiffcmp" function. Use the "tiffcmp" function to compare each page to a known blank TIFF image.
If the blank image is found, return the page number and use the RemoveByPage function to remove the blank page.

Notes The TIFFStreamOpen function was useful in some cases, but in others errors were thrown regarding missing tags when the stream was used.

Tests

The code includes tests for all functions:
TestRemoveByPage
TestRemoveBlankPage
TestMergeTiffs

About

win32 console app to manipulate TIFF images using tifflib 4.0.10

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published