2001.06.15 03:49 "Image manipulation package based on libtiff?", by Pak Yan Choi

2001.06.15 19:52 "Re: Image manipulation package based on libtiff?", by Joel Schumacher

The online docs do state:

Note that unlike the stdio library TIFF image files may not be opened
for both reading and writing; there is no support for altering the
contents of a TIFF file.

This probably seems doable, but seems a difficult task. It seems the method employed with libtiff would be to read page(s) from one file (or from memory) and add them to another. So you'd have to write a whole new file, putting your changes into that file, not modify the existing one.

It probably *could* be done, and libtiff might be able to be modified to handle it, but think of all you have to take care of.

With a few small changes, your whole image compression could grow, causing the image to no longer fit where it once was. Or to shrink, leaving big gaps of unused space in the middle of the image, which is inefficient.

Seeing as though TIFF is a multi-page format, you have to be aware of what space is being used by other pages. You can't just keep writing one page if it's now bigger for fear of overwriting another.

And, theoretically, there could be image tags that point to data stored who knows where throughout the file? You have to be careful not to step on those.

Probably the most efficient approach would be to give up the space used by the page originally, reclaim that space (for both the image, probably the image header, and data pointed to by the tags in the header) and do a relocate of all the other page(s), image headers, data, etc. in the rest of the file, then put your changes for the page you're altering at the end.

But by the time you do all that work, you'd probably be better off creating a new file, with all the pages in some sort of logical order.

Seems incredibly messy, in my opinion, and would probably take longer than an entire file rewrite.

What is this, some sort of classroom project? Seems like you have a goal to prove you can write a piece of code (which you seem to be asking others to do for you), but you're very open to how you do it. You don't even care if it's TIFF format or some other format. Sounds like a sort of open-ended classroom assignment, not real-world type of stuff.

Well, most other formats would be easier, as they are not multi-page. But you'd still probably end up re-writing the entire file, not doing a modification.

Maybe try some uncompressed format like Windows BMP files. You should be able to directly address portions of those files and modify specific areas without re-encoding/rewriting the entire file.

Joel Schumacher                    JCPenney Co. - UNIX Network Systems
jschumac@jcpenney.com              12700 Park Central Pl   M/S 6021
(972) 591-7543                     Dallas TX  75251