Merge pull request #3417 from kkopachev/issue-3413

Only ask for YCbCr->RGB libtiff conversion for jpeg-compressed tiffs
This commit is contained in:
Hugo 2018-10-19 21:58:39 +03:00 committed by GitHub
commit a2908734f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -173,6 +173,7 @@ int ImagingLibTiffDecode(Imaging im, ImagingCodecState state, UINT8* buffer, int
char *filename = "tempfile.tif";
char *mode = "r";
TIFF *tiff;
uint16 photometric = 0, compression;
/* buffer is the encoded file, bytes is the length of the encoded file */
@ -234,7 +235,12 @@ int ImagingLibTiffDecode(Imaging im, ImagingCodecState state, UINT8* buffer, int
}
}
TIFFGetFieldDefaulted(tiff, TIFFTAG_COMPRESSION, &compression);
TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric);
if (compression == COMPRESSION_JPEG && photometric == PHOTOMETRIC_YCBCR) {
/* Set pseudo-tag to force automatic YCbCr->RGB conversion */
TIFFSetField(tiff, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);
}
if (TIFFIsTiled(tiff)) {
uint32 x, y, tile_y;