AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2004.08.24 08:43 "[Tiff] Insetring text", by Alexandru, Ionita
2004.08.24 17:50 "Re: [Tiff] Insetring text", by Joris
2004.08.25 17:35 "[Tiff] Not-a-bug report, TIFFFdOpen (tif_win32) - TIFFClientOpen", by Joris
2004.08.25 17:57 "Re: [Tiff] Not-a-bug report, TIFFFdOpen (tif_win32) - TIFFClientOpen", by Frank Warmerdam
2004.08.26 04:46 "Re: [Tiff] Not-a-bug report, TIFFFdOpen (tif_win32) - TIFFClientOpen", by Ross A. Finlayson
2004.08.26 09:27 "Re: [Tiff] Not-a-bug report, TIFFFdOpen (tif_win32) - TIFFClientOpen", by Joris
2004.08.26 16:03 "Re: [Tiff] Not-a-bug report, TIFFFdOpen (tif_win32) - TIFFClientOpen", by Ross A. Finlayson
2004.08.25 19:08 "RE: [Tiff] Not-a-bug report, TIFFFdOpen (tif_win32) - TIFFClientOpen", by Neufeld Computer Services
2004.08.24 18:04 "Re: [Tiff] Insetring text", by Bob Friesenhahn

2004.08.24 17:50 "Re: [Tiff] Insetring text", by Joris

How can I access all pages of a multi-page tiff using imageMagick or

> graphicsMagick

I don't know about those packages...

to append to all of this, page numers, and how can I find out the number of pages in a multi-page tiff?

...but on the TIFF level, there is no way to know the number of pages, other then counting them. That is because each page only 'knows' about the location of the next one. May seem braindead, but it's actually a very convinient structure.

Counting them can be done with following code. (I'm not a C coder, but this is from the FM, start to R here: http://www.remotesensing.org/libtiff/libtiff.html.)

TIFF* tif = TIFFOpen('yada.tiff', "r");
if (tif) {
    int dircount = 0;
    do {
        dircount++;
    } while (TIFFReadDirectory(tif));
    /* dircount is your number of pages */
    TIFFClose(tif);
}

There is a function in tif_dir...

tdir_t
TIFFNumberOfDirectories(TIFF* tif)

...that seems to do the same, only it should be faster since it doesn't bother to read complete tagsets, and TIFFReadDirectory does (and may even decompress a jpeg strip and all, from what I've read in Bugzilla, but I may be wrong).

Oh, there's a page number tag...

I must annotate this files with page numbers in format 1/n, 2/n, 3/n.... n/n, where n is the total number of pages.

...that is two shorts, and has exactly this format (except that page numbers should start with 0). See http://www.awaresystems.be/imaging/tiff/tifftags/pagenumber.html. I wouldn't depend on it for reading purposes. (Because all sorts of things could have happend to it. It may have been correct in a file at first. Next, an application may have concattenated TIFF files, and left the PageNumber tag unchanged. Next, another tool could have unlinked some IFD's, or swapped some, or whatever. And also, it's not written most of the time to begin with.) But it might be suitable for your 'annotating' purposes.

Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be

Download your free TIFF tag viewer for windows here: http://www.awaresystems.be/imaging/tiff/astifftagviewer.html