2005.08.04 20:02 "[Tiff] NEWBIE HELP NEEDED: Efficiently changing orientation tags in multipage tiff files", by Bradley Feldman

Hi all:

I'm new to this library and this list and looking for some helpful tips on
writing a routine to quickly and efficiently change the orientation tag of
every page of a multipage file.

I see plenty of examples with single page files, but nothing with

As a primer, I've experimented with tiffset but found it only effects the
first page of a multitiff file.

Likewise, I've written a program that is basically simple loop that reads a
tiff file's directories, sets the orientation tag and writes out the
directory to a new file, but I'm not getting any image data. How so do I
get the whole input file, page by page with just the orientation changed to
the output file? I'm obviously missing some steps

Here's some pseudo code I'm using:

  infile = TIFFOpen("input.tif", "r");
  outfile = TIFFOpen("output.tif", "w");
   do {
      TIFFGetFieldDefaulted(infile, TIFFTAG_ORIENTATION, &orientation);
        orientation = newValue;
      TIFFSetField(infile, TIFFTAG_ORIENTATION, orientation);
      if (!TIFFWriteDirectory(outfile)) {
         (void) TIFFClose(outfile);
         (void) TIFFClose(infile);
         exit (-2);
   } while(TIFFReadDirectory(infile));

Many thanks in advance for any help you can provide me with!