AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
August 2004

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2004.08.24 08:43 "Insetring text", by Ionita Alexandru
2004.08.24 17:50 "Re: Insetring text", by Joris Van Damme
2004.08.24 18:04 "Re: Insetring text", by Bob Friesenhahn

2004.08.24 17:50 "Re: Insetring text", by Joris Van Damme

> 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