mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
only use TIFFReadRGBA* in case of o_jpeg compression
This commit is contained in:
parent
f2020eeab4
commit
169bb4842f
|
@ -824,14 +824,12 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
assert_image_similar_tofile(im, "Tests/images/pil_sample_cmyk.jpg", 0.5)
|
||||
|
||||
@pytest.mark.valgrind_known_error(reason="Known Failing")
|
||||
@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian")
|
||||
def test_strip_ycbcr_jpeg_2x2_sampling(self):
|
||||
infile = "Tests/images/tiff_strip_ycbcr_jpeg_2x2_sampling.tif"
|
||||
with Image.open(infile) as im:
|
||||
assert_image_similar_tofile(im, "Tests/images/flower.jpg", 0.5)
|
||||
|
||||
@pytest.mark.valgrind_known_error(reason="Known Failing")
|
||||
@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian")
|
||||
def test_strip_ycbcr_jpeg_1x1_sampling(self):
|
||||
infile = "Tests/images/tiff_strip_ycbcr_jpeg_1x1_sampling.tif"
|
||||
with Image.open(infile) as im:
|
||||
|
@ -843,14 +841,12 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
assert_image_similar_tofile(im, "Tests/images/pil_sample_cmyk.jpg", 0.5)
|
||||
|
||||
@pytest.mark.valgrind_known_error(reason="Known Failing")
|
||||
@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian")
|
||||
def test_tiled_ycbcr_jpeg_1x1_sampling(self):
|
||||
infile = "Tests/images/tiff_tiled_ycbcr_jpeg_1x1_sampling.tif"
|
||||
with Image.open(infile) as im:
|
||||
assert_image_equal_tofile(im, "Tests/images/flower2.jpg")
|
||||
|
||||
@pytest.mark.valgrind_known_error(reason="Known Failing")
|
||||
@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian")
|
||||
def test_tiled_ycbcr_jpeg_2x2_sampling(self):
|
||||
infile = "Tests/images/tiff_tiled_ycbcr_jpeg_2x2_sampling.tif"
|
||||
with Image.open(infile) as im:
|
||||
|
|
|
@ -1324,6 +1324,15 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
if ";16L" in rawmode:
|
||||
rawmode = rawmode.replace(";16L", ";16N")
|
||||
|
||||
# YCbCr images with new jpeg compression with pixels in one plane
|
||||
# unpacked straight into RGB values
|
||||
if (
|
||||
photo == 6
|
||||
and self._compression == "jpeg"
|
||||
and self._planar_configuration == 1
|
||||
):
|
||||
rawmode = "RGB"
|
||||
|
||||
# Offset in the tile tuple is 0, we go from 0,0 to
|
||||
# w,h, and we only do this once -- eds
|
||||
a = (rawmode, self._compression, False, self.tag_v2.offset)
|
||||
|
|
|
@ -407,6 +407,7 @@ ImagingLibTiffDecode(
|
|||
char *mode = "r";
|
||||
TIFF *tiff;
|
||||
uint16 photometric = 0; // init to not PHOTOMETRIC_YCBCR
|
||||
uint16 compression;
|
||||
int isYCbCr = 0;
|
||||
uint16 planarconfig = 0;
|
||||
int planes = 1;
|
||||
|
@ -509,9 +510,17 @@ ImagingLibTiffDecode(
|
|||
|
||||
|
||||
TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric);
|
||||
isYCbCr = photometric == PHOTOMETRIC_YCBCR;
|
||||
TIFFGetField(tiff, TIFFTAG_COMPRESSION, &compression);
|
||||
TIFFGetFieldDefaulted(tiff, TIFFTAG_PLANARCONFIG, &planarconfig);
|
||||
|
||||
isYCbCr = photometric == PHOTOMETRIC_YCBCR;
|
||||
|
||||
if (isYCbCr && compression == COMPRESSION_JPEG && planarconfig == PLANARCONFIG_CONTIG) {
|
||||
// If using new JPEG compression, let libjpeg do RGB convertion
|
||||
TIFFSetField(tiff, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);
|
||||
isYCbCr = 0;
|
||||
}
|
||||
|
||||
// YCbCr data is read as RGB by libtiff and we don't need to worry about planar storage in that case
|
||||
// if number of bands is 1, there is no difference with contig case
|
||||
if (planarconfig == PLANARCONFIG_SEPARATE &&
|
||||
|
|
Loading…
Reference in New Issue
Block a user