AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
May 2006

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

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

2006.05.09 21:55 "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.

Jason