2005.04.29 22:52 "[Tiff] Color TIFF/JPEG compression questions", by Jason Frank

2005.05.02 17:55 "Re: [Tiff] Color TIFF/JPEG compression questions", by Joris Van Damme

tiff2rgba  -c jpeg -r 16 quad-jpeg.tif  quad-jpeg-rgb.tif

This gave me a file with the following tags:

tiffinfo quad-jpeg-rgb.tif
TIFF Directory at offset 0xdb28
  Image Width: 512 Image Length: 384
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: RGB color
  Extra Samples: 1<assoc-alpha>
  YCbCr Subsampling: 2, 2
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 4
  Rows/Strip: 16
  Planar Configuration: single image plane
  Software: LIBTIFF, Version 3.7.2 Copyright (c) 1988-1996 Sam Leffler Copyright (c) 1991-1996 Silicon Graphics, Inc.
  JPEG Tables: (289 bytes)

tiff2rgba most certainly produces a buggy image here.

My source image has these tags:

TIFF Directory at offset 0x5b6e
  Image Width: 512 Image Length: 384
  Position: 0, 0
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  YCbCr Subsampling: 2, 2
  Samples/Pixel: 3
  Rows/Strip: 16
  Planar Configuration: single image plane
  Reference Black/White:
     0: 0 255
     1: 128 255
     2: 128 255
  JPEG Tables: (574 bytes)

Interestingly, the tagdump produced by AsTiffTagViewer is slightly different:

ImageWidth (1 Short): 512
ImageLength (1 Short): 384
BitsPerSample (3 Short): 8, 8, 8
Compression (1 Short): JPEG Technote #2
Photometric (1 Short): YCbCr
StripOffsets (24 Long): 8, 175, 342, 633, 2227, 3683, 5112, 6553,...
SamplesPerPixel (1 Short): 3
RowsPerStrip (1 Short): 16
StripByteCounts (24 Long): 167, 167, 291, 1594, 1456, 1429, 1441, 1114,...
PlanarConfig (1 Short): Contig
XPosition (1 Rational): 0
YPosition (1 Rational): 0
JpegTables (574 Undefined):
ReferenceBlackWhite (6 Rational):

There's no YCbCrSubsampling tag here. Thus, tiffinfo clearly brings defaults into the picture, which is not ideal when the purpose is discovering what tags are there.

It looks like tiff2rgba retained the YCbCr field. And, for some reason the source file has JPEG Tables, which I thought were used under Type 6 compressions. I don't know if that's expected, but I thought I'd pass it on.

JpegTables is a valid compression 7 new-style jpeg-in-tiff tag. It contains a 'tables-only jpeg'. In this case, that is an SOI marker (start of image), 2 DQT markers (quantization tables), 4 DHT markers (huffman tables), and an EOI marker (end of image). The actual strips are then allowed to contain jpegs without tables, so-called 'abbreviated' jpeg streams. In this case, first strip contains SOI marker, immediatelly followed by a SOF0 and SOS marker, the compressed data, and trailing EOI.

This tag is used to group common tables, used in all strips/tiles, into one single tables-only jpeg, to save space. Such usuage is actually even supported by the JPEG specification, and the JpegTables tag thus is a quite logical element of compression 7, even though it is not mandatory, tables can also be specified inside each tile/strip jpeg stream.

Thus, quad-jpeg.tif is perfectly fine, as far as I can see.

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