diff options
author | Bob Friesenhahn <bfriesen@simple.dallas.tx.us> | 2010-06-11 20:50:55 +0000 |
---|---|---|
committer | Bob Friesenhahn <bfriesen@simple.dallas.tx.us> | 2010-06-11 20:50:55 +0000 |
commit | 8cc559729c7346dc015c860c4be5da8fa054a004 (patch) | |
tree | 15cbcf1dd260ef364e037ffa79a5af3f9f425c0d | |
parent | 0b6e46201b984c0a38cc2fd59964135cc66a9c9e (diff) | |
download | libtiff-git-8cc559729c7346dc015c860c4be5da8fa054a004.tar.gz |
* tools/tiffcp.c (tiffcp): Applied Tom Lane's patch to reject
YCbCr subsampled data since tiffcp currently doesn't support it.
http://bugzilla.maptools.org/show_bug.cgi?id=2097
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | tools/tiffcp.c | 45 |
2 files changed, 29 insertions, 20 deletions
@@ -1,5 +1,9 @@ 2010-06-11 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> + * tools/tiffcp.c (tiffcp): Applied Tom Lane's patch to reject + YCbCr subsampled data since tiffcp currently doesn't support it. + http://bugzilla.maptools.org/show_bug.cgi?id=2097 + * Update libtool to version 2.2.10. 2010-06-10 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> diff --git a/tools/tiffcp.c b/tools/tiffcp.c index 24985e85..48319fa1 100644 --- a/tools/tiffcp.c +++ b/tools/tiffcp.c @@ -1,4 +1,4 @@ -/* $Id: tiffcp.c,v 1.37.2.7 2010-06-11 20:43:19 bfriesen Exp $ */ +/* $Id: tiffcp.c,v 1.37.2.8 2010-06-11 20:50:55 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -555,6 +555,7 @@ static int tiffcp(TIFF* in, TIFF* out) { uint16 bitspersample, samplesperpixel; + uint16 input_compression, input_photometric; copyFunc cf; uint32 width, length; struct cpTag* p; @@ -567,26 +568,30 @@ tiffcp(TIFF* in, TIFF* out) TIFFSetField(out, TIFFTAG_COMPRESSION, compression); else CopyField(TIFFTAG_COMPRESSION, compression); + TIFFGetFieldDefaulted(in, TIFFTAG_COMPRESSION, &input_compression); + TIFFGetFieldDefaulted(in, TIFFTAG_PHOTOMETRIC, &input_photometric); + if (input_compression == COMPRESSION_JPEG) { + /* Force conversion to RGB */ + TIFFSetField(in, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + } else if (input_photometric == PHOTOMETRIC_YCBCR) { + /* Otherwise, can't handle subsampled input */ + uint16 subsamplinghor,subsamplingver; + + TIFFGetFieldDefaulted(in, TIFFTAG_YCBCRSUBSAMPLING, + &subsamplinghor, &subsamplingver); + if (subsamplinghor!=1 || subsamplingver!=1) { + fprintf(stderr, "tiffcp: %s: Can't copy/convert subsampled image.\n", + TIFFFileName(in)); + return FALSE; + } + } if (compression == COMPRESSION_JPEG) { - uint16 input_compression, input_photometric; - - if (TIFFGetField(in, TIFFTAG_COMPRESSION, &input_compression) - && input_compression == COMPRESSION_JPEG) { - TIFFSetField(in, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); - } - if (TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &input_photometric)) { - if(input_photometric == PHOTOMETRIC_RGB) { - if (jpegcolormode == JPEGCOLORMODE_RGB) - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, - PHOTOMETRIC_YCBCR); - else - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, - PHOTOMETRIC_RGB); - } else - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, - input_photometric); - } - } + if (input_photometric == PHOTOMETRIC_RGB && + jpegcolormode == JPEGCOLORMODE_RGB) + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); + else + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, input_photometric); + } else if (compression == COMPRESSION_SGILOG || compression == COMPRESSION_SGILOG24) TIFFSetField(out, TIFFTAG_PHOTOMETRIC, |