AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2008.09.23 23:34 "[Tiff] TIFF Image Quality Question", by Rick Cone, Secure Payment Systems
2008.09.24 00:11 "Re: [Tiff] TIFF Image Quality Question", by Bob Friesenhahn
2008.10.01 23:18 "Re: [Tiff] Image Orientation tag and rotating images", by Richard Nolde
2008.10.01 03:03 "[Tiff] Image Orientation tag and rotating images", by Richard Nolde
2008.10.01 12:38 "Re: [Tiff] Image Orientation tag and rotating images", by Dr. Michael J. Chudobiak
2008.10.01 14:25 "Re: [Tiff] Image Orientation tag and rotating images", by Richard Nolde
2008.10.01 16:32 "Re: [Tiff] Image Orientation tag and rotating images", by Richard Nolde
2008.10.01 18:59 "Re: [Tiff] Image Orientation tag and rotating images", by Dr. Michael J. Chudobiak
2008.10.02 05:43 "Re: [Tiff] Image Orientation tag and rotating images", by Andrey Kiselev
2008.10.01 15:08 "Re: [Tiff] Image Orientation tag and rotating images", by Bob Friesenhahn
2008.10.01 16:02 "Re: [Tiff] Image Orientation tag and rotating images", by Edward Lam
2008.10.02 02:42 "Re: [Tiff] Image Orientation tag and rotating images", by Bob Friesenhahn
2008.09.24 01:14 "Re: [Tiff] TIFF Image Quality Question", by Phillip Crews

2008.10.01 16:32 "Re: [Tiff] Image Orientation tag and rotating images", by Richard Nolde

My first question is whether I have made the correct adjustments to the orientation tag for rotations of 90, 180, and 270 degrees clockwise.

Some comments:

  1. libtiff support for orientation is a little odd, because libtiff automatically adjusts for orientations 1-4 (which preserve the height and width), but not 5-8 (which swap height and width). Beware!

What file are you referring to when you say that libtiff automatically adjusts for orientations 1- 4? I should have noted that I am using the TIFFReadScanline and TIFFReadTile interfaces, not the TIFFReadRGBAImage interface as found in tif_getimage.c. The current code to read and write images is based on tiffcp.c which includes the following lines for determining and then updating the orientation tag. This code suggests to me that the issue is in the TIFFReadScanline and TIFFReadTile functions which do not have any options to reverse the data in the input stream if the orientation is right-handed as do TIFFReadRGBAImage related functions in tif_getimage.c. It would not be hard to add this functionality, but it isn't clear that it is going to solve anything for the readers that don't handle the orientation tag properly.

  TIFFGetFieldDefaulted(in, TIFFTAG_ORIENTATION, &orientation);
  switch (orientation) {

    case ORIENTATION_BOTRIGHT:
    case ORIENTATION_RIGHTBOT:    /* XXX */
         TIFFWarning(TIFFFileName(in), "using bottom-left orientation");
         orientation = ORIENTATION_BOTLEFT;
         /* fall thru... */
    case ORIENTATION_LEFTBOT:    /* XXX */
    case ORIENTATION_BOTLEFT:
         break;
    case ORIENTATION_TOPRIGHT:
    case ORIENTATION_RIGHTTOP:    /* XXX */

    default:
         TIFFWarning(TIFFFileName(in), "using top-left orientation");
         orientation = ORIENTATION_TOPLEFT;
         /* fall thru... */
    case ORIENTATION_LEFTTOP: /* XXX */
    case ORIENTATION_TOPLEFT:
         break;
   }

  TIFFSetField(out, TIFFTAG_ORIENTATION, orientation);

which I have replaced with

  TIFFSetField(out, TIFFTAG_ORIENTATION, image->orientation);

where image->orientation is set by the code previously noted based on the original orientation and the desired rotation.

3) If you transform the data to reflect the orientation tag, the orientation tag should be reset to "top left", or be removed entirely.

However, in my case, I am not transforming the data to reflect the orientation tag, rather as a specific request to rotate the image by a multiple of 90 degrees. This leaves open the possibility that images that did not have an orientation of TOPLEFT originally will still not display properly in some applications since the code above does not handle all orientations. It forces the orientation tag to a left-handed, top or bottom, value.

4) Orientation tag support for tiff is spotty, so the safest route is to transform the data and remove the orientation tag.

One final question about what the proper behavior should be since this is not a display application. Should the data be transformed to ORIENTATION_TOPLEFT when an image with any other orientation is loaded into memory under the assumption that this is the correct viewing orientation? Any requested rotations would then be made relative to the adjusted viewing orientation rather than to the original orientation. Or should rotations be relative to the original image orientation without regard to the proper viewing orientation. This is what I am doing now. In either case, it seems like resetting the orientation to TOPLEFT is appropriate when the data are transformed.

Does anyone have images with orientations other than TOPLEFT that are small enough to use for testing?

Richard