overstimulate

Tiff Counter

Tue, 19 Apr 2005 comments
Ever needed a Tiff counter? Don't want to pay lots of money or need the information in a specific format? Grab "LibTIFF":http://libtiff.org then compile the following:
#include "tiffio.h"
main(int argc, char* argv[])
{
    TIFF* tif = TIFFOpen(argv[1], "r");

    // a "directory" is a page in a multipage tiff

    if (tif) {
	int dircount = 0;
	do {
	 dircount++;
	} while (TIFFReadDirectory(tif));
	printf("%d directories in %s\n", dircount, argv[1]);
	TIFFClose(tif);
    }
}
Yeah, it is C/C++ but sometimes you have to.

Responses to "Tiff Counter"

  1. Mon, 19 Sep 2005 Tony Buser says:
    You know you can replace all that with a single line? :) LibTIFF comes with a program called tiffinfo, you can grep the word TIFF Directory and count it's output like so: tiffinfo filename.tif | grep 'TIFF Directory' | wc -l

Leave a response

My Card Add to your Address Book

Jesse Andrews
open source, web browsers, web services, web sites & folk dancing. contacts/sites

Keep Up To Date

Get updates via RSS or
get email when I blog

Previous Blog Posts