summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Friesenhahn <bfriesen@simple.dallas.tx.us>2010-06-11 21:23:12 +0000
committerBob Friesenhahn <bfriesen@simple.dallas.tx.us>2010-06-11 21:23:12 +0000
commitbbf76bce0f84cdcde4a754a6fdd3319e0615658c (patch)
treed9e487dfc4cd41518233a2cdba5066ca67bd58be
parent5ec011cfe78a36244d9ec23aeeb789ae3dcc1bf1 (diff)
downloadlibtiff-git-bbf76bce0f84cdcde4a754a6fdd3319e0615658c.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--ChangeLog4
-rw-r--r--tools/tiffcp.c43
2 files changed, 28 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 40c64082..4ef6c035 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 ebed5be6..0b473c8f 100644
--- a/tools/tiffcp.c
+++ b/tools/tiffcp.c
@@ -1,4 +1,4 @@
-/* $Id: tiffcp.c,v 1.45 2010-06-09 17:17:13 bfriesen Exp $ */
+/* $Id: tiffcp.c,v 1.46 2010-06-11 21:23:12 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -564,6 +564,7 @@ static int
tiffcp(TIFF* in, TIFF* out)
{
uint16 bitspersample, samplesperpixel;
+ uint16 input_compression, input_photometric;
copyFunc cf;
uint32 width, length;
struct cpTag* p;
@@ -576,26 +577,30 @@ tiffcp(TIFF* in, TIFF* out)
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
else
CopyField(TIFFTAG_COMPRESSION, compression);
- 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);
+ 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) {
+ 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,