From dbd98ba86ceb0c44b5da1544a9d0086ddda328a3 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 19 Jan 2015 22:01:13 +0000 Subject: [PATCH] disable chroma subsample in jpeg-tiff if Q>=90 see https://github.com/jcupitt/libvips/issues/218 --- ChangeLog | 1 + libvips/foreign/vips2tiff.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3dcb60ba..3b5b7b4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ - renamed VIPS_FOREIGN_DZ_DEPTH_1 as VIPS_FOREIGN_DZ_DEPTH_ONE etc. to help bindings - vipsthumbnail will return an error code if one or more conversions failed +- disable chroma subsample in jpeg-tiff if Q >= 90 24/12/14 started 7.42.1 - add gobject-2.0 to Requires: in vips and vips-cpp .pc files diff --git a/libvips/foreign/vips2tiff.c b/libvips/foreign/vips2tiff.c index b330765d..c0003807 100644 --- a/libvips/foreign/vips2tiff.c +++ b/libvips/foreign/vips2tiff.c @@ -144,6 +144,8 @@ * - embed XMP in output * 10/12/14 * - zero out edge tile buffers before jpeg write, thanks iwbh15 + * 19/1/15 + * - disable chroma subsample if Q >= 90 */ /* @@ -575,7 +577,7 @@ write_tiff_header( TiffWrite *tw, TIFF *tif, int width, int height ) else if( tw->compression == COMPRESSION_JPEG && tw->im->Bands == 3 && tw->im->BandFmt == VIPS_FORMAT_UCHAR && - !tw->rgbjpeg ) { + (!tw->rgbjpeg && tw->jpqual < 90) ) { /* This signals to libjpeg that it can do * YCbCr chrominance subsampling from RGB, not * that we will supply the image as YCbCr. @@ -1493,8 +1495,11 @@ tiff_copy( TiffWrite *tw, TIFF *out, TIFF *in ) tw->im->BandFmt == VIPS_FORMAT_UCHAR ) { /* Enable rgb->ycbcr conversion in the jpeg write. */ - TIFFSetField( out, - TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB ); + if( !tw->rgbjpeg && + tw->jpqual >= 90 ) + TIFFSetField( out, + TIFFTAG_JPEGCOLORMODE, + JPEGCOLORMODE_RGB ); /* And we want ycbcr expanded to rgb on read. Otherwise * TIFFTileSize() will give us the size of a chrominance