mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
Add TIFFTAG_SAMPLEFORMAT to blocklist (#3926)
Add TIFFTAG_SAMPLEFORMAT to blocklist
This commit is contained in:
commit
4758bca621
|
@ -4,7 +4,7 @@ import sys
|
|||
|
||||
from .helper import unittest, PillowTestCase, hopper
|
||||
|
||||
from PIL import Image, TiffImagePlugin
|
||||
from PIL import Image, TiffImagePlugin, features
|
||||
from PIL._util import py3
|
||||
from PIL.TiffImagePlugin import X_RESOLUTION, Y_RESOLUTION, RESOLUTION_UNIT
|
||||
|
||||
|
@ -587,6 +587,30 @@ class TestFileTiff(PillowTestCase):
|
|||
im.load()
|
||||
self.assertFalse(fp.closed)
|
||||
|
||||
@unittest.skipUnless(features.check("libtiff"), "libtiff not installed")
|
||||
def test_sampleformat_not_corrupted(self):
|
||||
# Assert that a TIFF image with SampleFormat=UINT tag is not corrupted
|
||||
# when saving to a new file.
|
||||
# Pillow 6.0 fails with "OSError: cannot identify image file".
|
||||
import base64
|
||||
|
||||
tiff = BytesIO(
|
||||
base64.b64decode(
|
||||
b"SUkqAAgAAAAPAP4ABAABAAAAAAAAAAABBAABAAAAAQAAAAEBBAABAAAAAQAA"
|
||||
b"AAIBAwADAAAAwgAAAAMBAwABAAAACAAAAAYBAwABAAAAAgAAABEBBAABAAAA"
|
||||
b"4AAAABUBAwABAAAAAwAAABYBBAABAAAAAQAAABcBBAABAAAACwAAABoBBQAB"
|
||||
b"AAAAyAAAABsBBQABAAAA0AAAABwBAwABAAAAAQAAACgBAwABAAAAAQAAAFMB"
|
||||
b"AwADAAAA2AAAAAAAAAAIAAgACAABAAAAAQAAAAEAAAABAAAAAQABAAEAAAB4"
|
||||
b"nGNgYAAAAAMAAQ=="
|
||||
)
|
||||
)
|
||||
out = BytesIO()
|
||||
with Image.open(tiff) as im:
|
||||
im.save(out, format="tiff")
|
||||
out.seek(0)
|
||||
with Image.open(out) as im:
|
||||
im.load()
|
||||
|
||||
|
||||
@unittest.skipUnless(sys.platform.startswith("win32"), "Windows only")
|
||||
class TestFileTiffW32(PillowTestCase):
|
||||
|
|
|
@ -1540,7 +1540,7 @@ def _save(im, fp, filename):
|
|||
|
||||
# STRIPOFFSETS and STRIPBYTECOUNTS are added by the library
|
||||
# based on the data in the strip.
|
||||
blocklist = [STRIPOFFSETS, STRIPBYTECOUNTS]
|
||||
blocklist = [STRIPOFFSETS, STRIPBYTECOUNTS, SAMPLEFORMAT]
|
||||
atts = {}
|
||||
# bits per sample is a single short in the tiff directory, not a list.
|
||||
atts[BITSPERSAMPLE] = bits[0]
|
||||
|
|
Loading…
Reference in New Issue
Block a user