AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2010.12.14 17:55 "[Tiff] patch to tif_jpeg.c", by Dwight Kelly
2010.12.15 00:00 "Re: [Tiff] patch to tif_jpeg.c", by Lee Howard
2011.01.01 13:41 "[Tiff] Regression in libtiff 4.0 CVS when creating a JPEG RGB contig", by Even Rouault
[...]

2010.12.14 17:55 "[Tiff] patch to tif_jpeg.c", by Dwight Kelly

Hello, I would like to submit the following patch to correctly set JPEG colorspace. Current code uses JCS_UNKNOWN for input colorspaces other than ycbcr. This causes problems with some decoders including Apple iOS 4.2.1.

Index: tif_jpeg.c

=================================================================== RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tif_jpeg.c,v retrieving revision 1.50.2.14

diff -r1.50.2.14 tif_jpeg.c
1361,1362c1361,1369
< sp->cinfo.c.in_color_space = JCS_UNKNOWN;
< if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN))
---
 > if (td->td_photometric == PHOTOMETRIC_MINISWHITE ||
td->td_photometric == PHOTOMETRIC_MINISBLACK)

 >                  sp->cinfo.c.in_color_space = JCS_GRAYSCALE;
 >              else if (td->td_photometric == PHOTOMETRIC_RGB)
 >                  sp->cinfo.c.in_color_space = JCS_RGB;
 >              else if (td->td_photometric == PHOTOMETRIC_SEPARATED && 

td->td_samplesperpixel == 4)
 > sp->cinfo.c.in_color_space = JCS_CMYK;
 > else
 > sp->cinfo.c.in_color_space = JCS_UNKNOWN;
 > if (!TIFFjpeg_set_colorspace(sp,

(sp->cinfo.c.in_color_space == JCS_RGB)? JCS_YCbCr: sp->cinfo.c.in_color_space))