2005.04.29 22:52 "[Tiff] Color TIFF/JPEG compression questions", by Jason Frank
I've finally have to dig into the horror that is color TIF's. What a mismash of different levels of support among different vendors. In any case, I've browbeat Snowbound into supporting Compression Type 7, and I've got an image they've produced. I am seeing some oddities with it though, and I'm wondering if it's even valid. Since I trust libtiff like my mother, I'm guessing it isn't.
Using libtiff 3.7.2, I get the following results:
First, the file was one big stripe, I need to fix that. In particular, tiffcp doesn't appreciate large stripes. The following command works fine with YCbCr colorspace, but doesn't with RGB (which is what this image is, and what I need).
tiffcp -s -r 16 1.tif 1_fixedstripe.tif
TIFFReadDirectory: Warning, 1.tif: unknown field with tag 513 (0x201) encountered.
JPEGPreDecode: Warning, Improper JPEG sampling factors 2,1 Apparently should be 1,1..
JPEGPreDecode: Warning, Decompressor will try reading with sampling 2,1..
Segmentation Fault (core dumped)
I don't know this fancy pants JPEG stuff, but I'm suspicious of this behavior. Seg faults always worry me. I have to wonder if the file is a legitimate TIFF image now. Tiffinfo reports the following for the first page:
TIFF Directory at offset 0x8
Subfile Type: (0 = 0x0)
Image Width: 856 Image Length: 1404
Resolution: 100, 100 pixels/inch
Compression Scheme: JPEG
Photometric Interpretation: RGB color
YCbCr Subsampling: 2, 2
Artist: "2004 SNOWBOUND, ALL RIGHTS RESERVED"
Date & Time: "12-24-2004"
Orientation: row 0 top, col 0 lhs
Planar Configuration: single image plane
Tag 513: 504
And tiffdump says this:
Magic: 0x4949 <little-endian>
Version: 0x2a Directory 0: offset 8 (0x8)
next 182416 (0x2c890)
SubFileType (254) LONG (4)
ImageWidth (256) LONG (4) 1 <856>
ImageLength (257) LONG (4) 1 <1404>
BitsPerSample (258) SHORT (3) 3 <8 8 8>
Compression (259) SHORT (3) 1 <7>
Photometric (262) SHORT (3) 1 <2>
FillOrder (266) SHORT (3) 1 <1>
StripOffsets (273) LONG (4) 1 <504>
Orientation (274) SHORT (3) 1 <1>
SamplesPerPixel (277) SHORT (3) 1 <3>
RowsPerStrip (278) LONG (4) 1 <1404>
StripByteCounts (279) LONG (4) 1 <181912>
XResolution (282) RATIONAL (5) 1 <100>
YResolution (283) RATIONAL (5) 1 <100>
PlanarConfig (284) SHORT (3) 1 <1>
ResolutionUnit (296) SHORT (3) 1 <2>
DateTime (306) ASCII (2) 20 <12-24-2004\0\0\0\0\0\0\0\0\0\0>
Artist (315) ASCII (2) 200 <2004 SNOWBOUND, ALL RIGH ...>
JPEGInterchangeFormat (513) LONG (4) 1 <504>
When I view the image in IrFan (and I've not been able to determine if they support Type 7 compression either...) The first page's background, which should be white, is pink, and the text, which should be black, is green. I know that I shouldn't be compressing bi-tonal with JPEG, but I'm using this as an example, since I know what the colors should be.
The biggest issue I have is that I can't find a viewer that I know supports color tiffs correctly. If someone has a recommendation there, I'd be very grateful.
Does anyone know where to go with this? Is the image invalid? Do I need to talk to Snowbound? Should I try to get a stack trace on the SEGV? Should I try to hack up a program to change the sampling factors internally and see if I can then process the file? Any advice would be appreciated.