Received: from sgi.sgi.com (192.48.153.1) by cerious.com
 with SMTP (Apple Internet Mail Server 1.1.1); Thu, 19 Dec 1996 05:17:45 -0500
Received: from cthulhu.engr.sgi.com (cthulhu.engr.sgi.com [192.26.80.2]) by sgi.sgi.com (950413.SGI.8.6.12/950213.SGI.AUTOCF) via ESMTP id CAA28359; Thu, 19 Dec 1996 02:11:20 -0800
Received: (from daemon@localhost) by cthulhu.engr.sgi.com (950413.SGI.8.6.12/960327.SGI.AUTOCF) id IAA20000 for tiff-list; Thu, 19 Dec 1996 08:43:08 GMT
Received: from sgi.sgi.com (sgi.engr.sgi.com [192.26.80.37]) by cthulhu.engr.sgi.com (950413.SGI.8.6.12/960327.SGI.AUTOCF) via ESMTP id AAA19991 for <tiff-relay@relay.engr.sgi.com>; Thu, 19 Dec 1996 00:43:07 -0800
Received: from extern.kampsax.dk (extern.kampsax.dk [193.88.186.19]) by sgi.sgi.com (950413.SGI.8.6.12/950213.SGI.AUTOCF) via ESMTP id AAA17950 for <tiff@sgi.com>; Thu, 19 Dec 1996 00:43:00 -0800
Received: (from smap@localhost) by extern.kampsax.dk (8.8.3/KxT-1996.12.09-KRS-extern) id JAA22938; Thu, 19 Dec 1996 09:45:04 +0100
Received: from portvagt.kxt.kampsax.dk(193.88.186.17) by extern.kampsax.dk via smap (V2.0beta)
	id xma022930; Thu, 19 Dec 96 09:44:32 +0100
Received: (from smap@localhost) by hval.kampsax.dk (8.8.3/KxT-1996.12.06-KRS) id JAA05242; Thu, 19 Dec 1996 09:41:58 +0100
Received: from rokke.kampsax.dk(192.168.10.106) by hval.kampsax.dk via smap (V2.0beta)
	id xma005240; Thu, 19 Dec 96 09:41:43 +0100
Received: from localhost (krs@localhost [127.0.0.1]) by rokke.kampsax.dk with SMTP (8.8.3/KxT-1996.12.06-KRS) id JAA05956; Thu, 19 Dec 1996 09:42:55 +0100
Message-Id: <199612190842.JAA05956@rokke.kampsax.dk>
X-Authentication-Warning: rokke.kampsax.dk: krs@localhost [127.0.0.1] didn't use HELO protocol
To: "Michael J. Callahan" <mikec@america.net>
Cc: tiff@sgi.com, krs@kampsax.dk
Subject: Re: Changing ORIENTATION of a TIFF  
In-reply-to: <Pine.SOL.3.91.961217134248.22234B-100000@atl1> 
Date: Thu, 19 Dec 96 09:42:55 +0100
From: "Karsten Spang" <krs@kampsax.dk>
X-Mts: smtp
Sender: owner-tiff@relay.engr.SGI.COM
Precedence: bulk
Status: R

In message <Pine.SOL.3.91.961217134248.22234B-100000@atl1> ,
"Michael J. Callahan" <mikec@america.net>  writes:

>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
