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
June 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.06.07 11:39 "Editing a tiff image using libtiff", by Sachin Garg
2006.06.07 12:51 "Re: Editing a tiff image using libtiff", by Joris Van Damme
2006.06.12 13:59 "Re: Editing a tiff image using libtiff", by Sachin Garg
2006.06.12 15:09 "Re: Editing a tiff image using libtiff", by Joris Van Damme
2006.06.13 07:29 "Re: Editing a tiff image using libtiff", by Rob Van Den Tillaart
2006.06.13 08:32 "Re: Editing a tiff image using libtiff", by Gerben Vos
2006.06.13 08:55 "Re: Editing a tiff image using libtiff", by Rob Van Den Tillaart
2006.06.13 16:04 "Re: Editing a tiff image using libtiff", by Joris Van Damme
2006.06.13 16:02 "Re: Editing a tiff image using libtiff", by Joris Van Damme
2006.06.14 09:08 "Re: Editing a tiff image using libtiff", by Gerben Vos

2006.06.07 12:51 "Re: Editing a tiff image using libtiff", by Joris Van Damme

Sachin,

Sachin Garg wrote:
> I am coding an application where I want to do a minor edit in a tiff
> image. The problem is that even a minor edit can change the compressed
> image size, and this will mean that all the offsets everywhere to all
> the tags/values after the compressed image data will have to updated.
>
> afaik, libtiff rewrites the entire tiff image with the directory at
> the end. However in cases where a user might have structured a tiff
> file as per his specific requirements, such restructuring for a minor
> edit may be too much to ask.
>
> I will like to be able to do this minor image edit while maintaining
> the existing tiff structure, but updating all the offsets seems an
> overwhelming task. Any suggestions on how I should tackle this
> situation?

I'm not sure what you mean by 'restructuring' or 'have structured a
tiff'...

Are you refering to the order of the different data blocks? In that
case, you're not talking about TIFF. There is no need for any specific
order of data blocks in TIFF. Thus, you can hold on to any that you
don't change in this 'minor edit' operation, and have the new IFD point
to exactly those old locations. Any that do change, you can append to
the file, or, if the new size does not exceed the old, write in the old
location. Next, you can write an updated IFD, again, either appended to
the file, taking care to update old offset at the end of previous IFD,
or, if size of new IFD does not exceed old, you can overwrite the old
IFD.

For example, suppose your minor edit operation does not affect image
size or anything, but merely changes a single tile. You can compute the
new tile size by pre-compressing it, worst case. If it fits the old
space, it fits, and the only thing that need updating is one entry in
the TileByteCounts tag. If it doesn't fit, append it, and the updating
is limited to one entry in the TileOffsets and one entry in the
TileByteCounts tag. This tag value or these tag values, can be changed
in place, since their size does not change. Thus, neither does the IFD
itself change, and you can leave that as it is.

Does this help? Or am I not understanding your question?

As to how to do this with LibTiff... That's another issue. But you seem
to indicate you're not using LibTiff anyway.


Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html