Skip to content

Commit 152ed62

Browse files
authored
Merge pull request #4100 from radarhere/tiff
Moved libtiff test into libtiff test file
2 parents d3ae7a1 + 4de1008 commit 152ed62

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

Tests/test_file_libtiff.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,3 +840,26 @@ def test_orientation(self):
840840
im.load()
841841

842842
self.assert_image_similar(base_im, im, 0.7)
843+
844+
def test_sampleformat_not_corrupted(self):
845+
# Assert that a TIFF image with SampleFormat=UINT tag is not corrupted
846+
# when saving to a new file.
847+
# Pillow 6.0 fails with "OSError: cannot identify image file".
848+
import base64
849+
850+
tiff = io.BytesIO(
851+
base64.b64decode(
852+
b"SUkqAAgAAAAPAP4ABAABAAAAAAAAAAABBAABAAAAAQAAAAEBBAABAAAAAQAA"
853+
b"AAIBAwADAAAAwgAAAAMBAwABAAAACAAAAAYBAwABAAAAAgAAABEBBAABAAAA"
854+
b"4AAAABUBAwABAAAAAwAAABYBBAABAAAAAQAAABcBBAABAAAACwAAABoBBQAB"
855+
b"AAAAyAAAABsBBQABAAAA0AAAABwBAwABAAAAAQAAACgBAwABAAAAAQAAAFMB"
856+
b"AwADAAAA2AAAAAAAAAAIAAgACAABAAAAAQAAAAEAAAABAAAAAQABAAEAAAB4"
857+
b"nGNgYAAAAAMAAQ=="
858+
)
859+
)
860+
out = io.BytesIO()
861+
with Image.open(tiff) as im:
862+
im.save(out, format="tiff")
863+
out.seek(0)
864+
with Image.open(out) as im:
865+
im.load()

Tests/test_file_tiff.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
from io import BytesIO
44

5-
from PIL import Image, TiffImagePlugin, features
5+
from PIL import Image, TiffImagePlugin
66
from PIL._util import py3
77
from PIL.TiffImagePlugin import RESOLUTION_UNIT, X_RESOLUTION, Y_RESOLUTION
88

@@ -587,30 +587,6 @@ def test_close_on_load_nonexclusive(self):
587587
im.load()
588588
self.assertFalse(fp.closed)
589589

590-
@unittest.skipUnless(features.check("libtiff"), "libtiff not installed")
591-
def test_sampleformat_not_corrupted(self):
592-
# Assert that a TIFF image with SampleFormat=UINT tag is not corrupted
593-
# when saving to a new file.
594-
# Pillow 6.0 fails with "OSError: cannot identify image file".
595-
import base64
596-
597-
tiff = BytesIO(
598-
base64.b64decode(
599-
b"SUkqAAgAAAAPAP4ABAABAAAAAAAAAAABBAABAAAAAQAAAAEBBAABAAAAAQAA"
600-
b"AAIBAwADAAAAwgAAAAMBAwABAAAACAAAAAYBAwABAAAAAgAAABEBBAABAAAA"
601-
b"4AAAABUBAwABAAAAAwAAABYBBAABAAAAAQAAABcBBAABAAAACwAAABoBBQAB"
602-
b"AAAAyAAAABsBBQABAAAA0AAAABwBAwABAAAAAQAAACgBAwABAAAAAQAAAFMB"
603-
b"AwADAAAA2AAAAAAAAAAIAAgACAABAAAAAQAAAAEAAAABAAAAAQABAAEAAAB4"
604-
b"nGNgYAAAAAMAAQ=="
605-
)
606-
)
607-
out = BytesIO()
608-
with Image.open(tiff) as im:
609-
im.save(out, format="tiff")
610-
out.seek(0)
611-
with Image.open(out) as im:
612-
im.load()
613-
614590

615591
@unittest.skipUnless(sys.platform.startswith("win32"), "Windows only")
616592
class TestFileTiffW32(PillowTestCase):

0 commit comments

Comments
 (0)