TIFF and LibTiff Mail List Archive


2006.05.09 21:55 "[Tiff] TIFF Rotation", by Jason Frank
2006.05.09 22:11 "Re: [Tiff] TIFF Rotation", by Bob Friesenhahn
2006.05.09 22:32 "Re: [Tiff] TIFF Rotation", by Edward Lam
2006.05.10 01:28 "Re: [Tiff] TIFF Rotation", by Joris Van Damme

2006.05.09 21:55 "[Tiff] TIFF Rotation", by Jason Frank

Well, I've tried to dodge this, but I don't see another option. I need to be able to rotate TIF's by 90, 180, or 270 degrees. Near as I can tell, there's not really any support for this in libtiff, and I don't want to pay the ImageMagick penalty for bi-tonal images. To be honest, performance is not a huge concern, since it will be done rarely at best. But, I can't afford ImageMagick's memory usage. Although I can probably accommodate a single uncompressed directory. So I guess I need to roll my own.

So far, I haven't found any code that does an honest to god image rotation in libtiff. I've found a couple programs that monkey with the orientation tag, but that's not usually a good approach, since not everyone supports the orientation flag correctly. If anyone knows of any other source code, I'm happy to use that instead.

What I'm trying to decide on is how to best do it, both from an algorithm perspective, and from a code organization perspective.

The first question is should this be a distinct program, an option for tiffcp, or both?

The second is that I'm willing to bet that a lot of the contents of tiffcp.c are going to be useful, especially the algorithms to convert tiles to strips and back. After all, the programs are going to be doing very similar work. That's because I envision my program converting to strips, uncompressing the data, iterating through the strips and putting things where they should be. Finally, it would put things back in tiles as necessary. But, since these are in tiffcp.c, they're not really accessible to other programs. How does everyone feel about moving a significant portion of the tiffcp.c contents into the libtiff library? Which functions and how exactly to do it are obviously up for debate...

How about a library function to reorient a TIF *? Then, if you need to mirror an image horizonally, you just change the orientation's X component (e.g. TOPLEFT to TOPRIGHT), to mirror vertically, you change the orientation's Y component (e.g. TOPLEFT TO BOTTOMLEFT). If you need a 180 degree rotation, I think you can just pick the opposite corner (e.g. TOPLEFT to BOTTOMRIGHT) Then, you would simply reorient it back to the original orientation. I would pretty much expect this function to leave everything else undisturbed (strips vs. tile, compression, etc.) Heck, I'd probably provide a mirrorhorizontal, mirrorvertical and rotate180 function to even do that work for us, but that's a design issue.

That would give me 1/3 of the functionality that I need, and provide some other useful functionality also.

I don't thing that works for a 90 or 270 degree rotation though. I think I have to actually march the strips and fill rows out as columns.

Anyway, I'm very happy to listen to suggestions on this.


<font size="1" face="arial">This message (including any attachments) may contain confidential or otherwise privileged information and is intended only for the individual(s) to which it is addressed. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secured or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message or that arise as a result of e-mail transmission. If verification is required please request a hard-copy version from the sender.

SOURCECORP, Incorporated