2003.04.30 11:18 "append and endianess", by Julien Demaria

2003.04.30 14:49 "Re: append and endianess", by Harring Figueiredo

I want to append a directory to an existing TIFF file.

My question is must I take care about endianess (by forcing the endianess of the appended file to its original endianess)?

Yes, you must take care of the correct endianess.

I have an old TIFF documentation that say "Cannot append to file that opposite byte ordering.... This is a limitation of the library." but the last doc doesn't say that.

If the input image is little-endian and I append on a big-endian machine, what will be the result endianess? (little-endian ?)

The result will be:

1) If the image is read on a little-endian, it will parse OK until it finds a Directory Entry (which you added) with a HUGE number pointing to some aread in the file/memory that does not exist.

All of the directory entries that you added will be read wrong by the application reading the file.

The TIFF header is the only place where an application can check for the endianess of the file. What will happen is that your offset will be wrong and will likely crash the application reading the TIFF file sine the spec says [paraphrasing the spec] -- an application MUST follow the pointer/offset of an IFD to wherever it might lead.

so, if in little endian you have, 1234, on big endian you will have 4321, which is clearly not the same.

I hope this helps.