Question

I have a program that takes in stacks of TIFF images and is very particular about the header data (it expects all headers to be the same), however I want to edit a couple of the images in the stack before sending it to this program.

Every program I've tried so far (Paint.net, MS Paint, ImageJ) has altered the header file or outright corrupted it when it saves the new images. I have access to C# and LibTiff.Net but even after reading the documents I'm confused as to how to simply replace the image data without changing the header information at all.

Currently the idea is simply to replace an image with a solid colour, so it isn't too complicated.

Was it helpful?

Solution

Here's how I would go about this.

Check TIFF documentation to find out where the actual bitmap data is stored. (I believe it is a structured format so it won't be at the same place every time, although it could be if all your headers are the same.)

Once you've identified the data, you can extract it or replace it with raw bitmap data of the same dimensions and format.

For example, you could extract the bitmap data from the TIFF file with the changed headers and overwrite the data in a file with a good header.

It's pretty low level, but it should work.

Alternatively, you could read-in the edited files and write back out a TIFF file with your own headers in the correct format. Might be more or less difficult.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top