2005.10.14 10:47 "[Tiff] Repair ImageLength of fax file", by Ulf Zibis

2005.10.14 16:05 "Re: [Tiff] Repair ImageLength of fax file", by Joris Van Damme

Ulf,

I suppose, the reason is the missing ImageLength (see dump below). Is there any chance to calculate the correct value.

Yes, there is, but it's so much trouble it may not be worth it.

G3 compressed data has EOL markers in it. It should start with an EOL marker (but a common error is to ommit the first EOL), and next give another EOL marker after each compressed line. In my opinion, it should end with a single EOL marker after the last line, but sources are not clear on this and you may see a variable number of EOLs after the last line, anything from 0 to 6.

An EOL marker is 12 bits, and goes like 000000000001. That pattern cannot occur in the actual compressed data. So scanning through the compressed data, counting the occurences of this pattern, making sure to deal with the first EOL or its absense, and the last EOL sequence specifically, you could derive an appropriate value for ImageLength.

Is it worth it? Do you have many such images that need decoding, or a buggy source you can't fix?

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