1996.12.17 18:44 "Changing ORIENTATION of a TIFF", by Michael J. Callahan

1996.12.19 08:42 "Re: Changing ORIENTATION of a TIFF", by Karsten Spang

The problem I have now concerns the fact that the TIFF images I am working with are saved such that their orientation value is 3. So the users are unhappy that the images come up in thier viewers with the right side on the left (reversed). The fact that they can flip them to read correctly in their viewers is not an appropriate solution for them/us.

In the TIFF 6.0 specification, top of page 37, it is stated that "Support for orientations other than 1 is not a Baseline TIFF requirement.", in other words, you should not expect a viewer to honor the Orientation tag!

It seems I most likely need to be able to read the existing image file, convert the TIFF data such that it's orientation will be an un-reversed value of 1, and then write a new TIFF file as a result.

I think you are right:-)

Can LibTiff be used for this? Has anyone done this? Do you have any insight as to how to accomplish this with that library? I have preliminarily looked at some documentation on it and it was not immeadiately clear to me how to begin, perhaps with more study.

Libtiff can be used for reading the old file, and writing the new file, but the rotation, you must do yourself. The rotaion 3->1 is 180 degrees, which is simply two flips. All you have to do, is to read the scan lines in reverse order, flip each of them, and write them out. If you are using compressed data, it will be probably be more efficient to read the input as strips in reverse order, and then take the scanlines out of the strip in reverse order.

Flipping a scan line depends on what kind of data you have. If they are bilevel, there is a routine in libtiff called TIFFReverseBits, which flips the bits in a bunch of bytes, such that you just have to flip the bytes.

Karsten
--------------------------------------------------------------------------------
E-mail: krs@kampsax.dk                                      Karsten Spang
Phone:  +45 36 39 08 00                                     Kampsax Technology
Fax:    +45 36 77 03 01                                     P.O. Box 1142
WWW:    http://www.kampsax.dk/~krs                          DK-2650 Hvidovre
                                                            Denmark