2004.05.18 17:47 "[Tiff] Recovering tiff faxes corrupted with 3.6.0", by Andrew McGill

2004.05.19 13:00 "[Tiff] Re: Recovering tiff faxes corrupted with 3.6.0", by Andrew McGill

Hi Frank

Thanks for the reply - I stayed up late in this time zone, and yes, I did find that hacking tiffset was not the joy I had intended. I did download a copy of the TIFF spec (6.0) from Adobe, and I found that the following fixes this corruption very neatly (and corrupts perfectly good tiff files as well):

#! /usr/bin/perl
# Public domain
# 266       03=short                      01=std, 02=rev
# Tag       Type      Count               Value
# 0    1    2    3    4    5    6    7    8
use English;
undef $IFS;
while(<>) {
        s{\x01\x03\x00\x01\x00\x00\x00\x02\x00}
         {\x01\x03\x00\x01\x00\x00\x00\x01\x00}sg;
        print;
}

The code searches for the "FillOrder" block tag = 0A01 type=0300 count=01000000 value=0200 and sets the value to 0100, which reverses the bit order. (I couldn't convince perl to search for \x0A which should be at the head of the block, so I left it off).

The reason this works, as I understand it is that libtiff (unpatched) reversed the fillorder in the data, but the header was marked as read-only. Reversing the fillorder in the header makes the files readable again.

You are welcome to put this in the contrib section or hide it in the documentation


Editor's note: This mail was not originally archived, and has been reconstructed from quotes.