AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2006.03.29 22:22 "[Tiff] TIFF_UPSAMPLED", by Frank Warmerdam
2006.03.30 18:44 "Re: [Tiff] TIFF_UPSAMPLED", by Antonio Scuri
2006.04.04 02:19 "[Tiff] New OJPEG support", by Joris
2006.04.04 03:28 "Re: [Tiff] New OJPEG support", by Bob Friesenhahn
2006.04.04 04:20 "Re: [Tiff] New OJPEG support", by Joris

2006.03.29 22:22 "[Tiff] TIFF_UPSAMPLED", by Frank Warmerdam

Folks,

For roughly the last six or seven years I have avoided writing YCbCr color

mode JPEG compressed TIFF files in my application because it seemed terribly complex to make it work. Every feeble attempt was defeated by lots of gobblygook from the library.

Well, finally a client has banged me over the head until I worked out why it wasn't working for me. It turns out that when writing stuff in RGB mode (for autoconversion to ycbcr) I was setting the TIFFTAG_JPEGCOLORMODE to RGB *before* I was setting TIFFTAG_PHOTOMETRIC to TIFFTAG_YCBCR. This resulted in the TIFF_UPSAMPLED flag being set improperly and it wasn't reset when the photometric interpretation was set.

The work around is to ensure that application code sets the JPEGCOLORMODE *after* the photometric interpretation. I have also made changes in the library to reset the upsampled flag when the photometric flag is set, so hopefully in the future applications won't be subject to this order of setting flags vagarity.

The larger lesson here might be that applications may be safer setting codec-specific flags and pseudo-flags *after* setting all the basic image configuration tags as the codec specific tags are the ones most likely to have odd conditions around them.

I just thought I would pass on what has been (for me) hard won wisdom.

Best regards,
--

---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGF, http://osgeo.org