AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

1998.06.11 15:09 "Damaged Tiff files", by Scott Kennedy
1998.06.19 22:43 "damaged tiff file update", by Scott Kennedy
1998.06.20 08:54 "Re: damaged tiff file update", by Frank D. Cringle

1998.06.20 08:54 "Re: damaged tiff file update", by Frank D. Cringle

I was dealing with group 4 compressed tifs, so importing the data in

that the data was compressed in a single strip. If I'm missing a few bytes from the beginning of the compressed strip, as is certain, is there anyway to decompress it correctly?

The short answer is: no.

A somewhat longer answer: well, maybe. The problem is that G4 encodes each line after the first line in terms of its difference from the preceding line. Also, it is a variable length code with no indication of the boundaries between code words or the boundaries between lines. As long as you start decoding at the beginning and there are no bit-errors, everything works out fine. But even a single bit error in G4 data generally makes the remainder of the image unreadable. If the image is computer-generated (rather than scanned from paper) you might conceivably find a white line, just below a line of text, that has been encoded in horizontal mode. For an image width of 1696 that would be the bitstream 001 011000 00011011 0000110111. Starting with those bits, feed the data into a G4 decoder and something sensible may come out. Unfortunately, that bit stream can occur by chance as part of some other code words starting at a different bit boundary.

Hmmm... Here is another strategy. Feed the data you have into a G4 decoder repeatedly, starting one bit further down the datastream on each attempt. Most attempts will produce garbage and the decoder will complain about incorrect line lengths, unknown extension codes and the like. But if you hit a line that was encoded without reference to its predecessor (or one whose predecessor happened to be pure white), the decoder will be correctly synchronised and the remainder of the image will come out OK.

--
Frank Cringle, fdc@cliwe.ping.de
voice: (+49 2304) 467101; fax: 943357