mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-04 21:50:54 +03:00
Merge pull request #5452 from radarhere/missing_samplesperpixel
Updated default value for SAMPLESPERPIXEL TIFF tag
This commit is contained in:
commit
f02739715d
BIN
Tests/images/old-style-jpeg-compression-no-samplesperpixel.tif
Normal file
BIN
Tests/images/old-style-jpeg-compression-no-samplesperpixel.tif
Normal file
Binary file not shown.
|
@ -912,8 +912,13 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
assert_image_equal_tofile(im, "Tests/images/tiff_16bit_RGBa_target.png")
|
assert_image_equal_tofile(im, "Tests/images/tiff_16bit_RGBa_target.png")
|
||||||
|
|
||||||
def test_old_style_jpeg(self):
|
def test_old_style_jpeg(self):
|
||||||
infile = "Tests/images/old-style-jpeg-compression.tif"
|
with Image.open("Tests/images/old-style-jpeg-compression.tif") as im:
|
||||||
with Image.open(infile) as im:
|
assert_image_equal_tofile(im, "Tests/images/old-style-jpeg-compression.png")
|
||||||
|
|
||||||
|
def test_open_missing_samplesperpixel(self):
|
||||||
|
with Image.open(
|
||||||
|
"Tests/images/old-style-jpeg-compression-no-samplesperpixel.tif"
|
||||||
|
) as im:
|
||||||
assert_image_equal_tofile(im, "Tests/images/old-style-jpeg-compression.png")
|
assert_image_equal_tofile(im, "Tests/images/old-style-jpeg-compression.png")
|
||||||
|
|
||||||
def test_no_rows_per_strip(self):
|
def test_no_rows_per_strip(self):
|
||||||
|
|
|
@ -1263,7 +1263,10 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
if bps_count > len(bps_tuple) and len(bps_tuple) == 1:
|
if bps_count > len(bps_tuple) and len(bps_tuple) == 1:
|
||||||
bps_tuple = bps_tuple * bps_count
|
bps_tuple = bps_tuple * bps_count
|
||||||
|
|
||||||
samplesPerPixel = self.tag_v2.get(SAMPLESPERPIXEL, 1)
|
samplesPerPixel = self.tag_v2.get(
|
||||||
|
SAMPLESPERPIXEL,
|
||||||
|
3 if self._compression == "tiff_jpeg" and photo in (2, 6) else 1,
|
||||||
|
)
|
||||||
if len(bps_tuple) != samplesPerPixel:
|
if len(bps_tuple) != samplesPerPixel:
|
||||||
raise SyntaxError("unknown data organization")
|
raise SyntaxError("unknown data organization")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user