mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 09:26:16 +03:00
Tests for multipage tiffs
This commit is contained in:
parent
f54bccab0e
commit
b8bdd13aac
BIN
Tests/images/multipage-lastframe.tif
Normal file
BIN
Tests/images/multipage-lastframe.tif
Normal file
Binary file not shown.
|
@ -312,6 +312,35 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
self.assertRaises(OSError, lambda: os.fstat(fn))
|
self.assertRaises(OSError, lambda: os.fstat(fn))
|
||||||
self.assertRaises(OSError, lambda: os.close(fn))
|
self.assertRaises(OSError, lambda: os.close(fn))
|
||||||
|
|
||||||
|
def test_multipage(self):
|
||||||
|
# issue #862
|
||||||
|
TiffImagePlugin.READ_LIBTIFF = True
|
||||||
|
im = Image.open('Tests/images/multipage.tiff')
|
||||||
|
# file is a multipage tiff, 10x10 green, 10x10 red, 20x20 blue
|
||||||
|
|
||||||
|
im.seek(0)
|
||||||
|
self.assertEqual(im.size, (10,10))
|
||||||
|
self.assertEqual(im.convert('RGB').getpixel((0,0)), (0,128,0))
|
||||||
|
self.assertTrue(im.tag.next)
|
||||||
|
|
||||||
|
im.seek(1)
|
||||||
|
self.assertEqual(im.size, (10,10))
|
||||||
|
self.assertEqual(im.convert('RGB').getpixel((0,0)), (255,0,0))
|
||||||
|
self.assertTrue(im.tag.next)
|
||||||
|
|
||||||
|
im.seek(2)
|
||||||
|
self.assertFalse(im.tag.next)
|
||||||
|
self.assertEqual(im.size, (20,20))
|
||||||
|
self.assertEqual(im.convert('RGB').getpixel((0,0)), (0,0,255))
|
||||||
|
|
||||||
|
TiffImagePlugin.READ_LIBTIFF = False
|
||||||
|
|
||||||
|
def test__next(self):
|
||||||
|
TiffImagePlugin.READ_LIBTIFF = True
|
||||||
|
im = Image.open('Tests/images/lena.tif')
|
||||||
|
self.assertFalse(im.tag.next)
|
||||||
|
im.load()
|
||||||
|
self.assertFalse(im.tag.next)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from helper import unittest, PillowTestCase, lena, py3
|
from helper import unittest, PillowTestCase, lena, py3
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image, TiffImagePlugin
|
||||||
|
|
||||||
|
|
||||||
class TestFileTiff(PillowTestCase):
|
class TestFileTiff(PillowTestCase):
|
||||||
|
@ -141,6 +141,32 @@ class TestFileTiff(PillowTestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
im.getextrema(), (-3.140936851501465, 3.140684127807617))
|
im.getextrema(), (-3.140936851501465, 3.140684127807617))
|
||||||
|
|
||||||
|
def test_multipage(self):
|
||||||
|
# issue #862
|
||||||
|
im = Image.open('Tests/images/multipage.tiff')
|
||||||
|
# file is a multipage tiff, 10x10 green, 10x10 red, 20x20 blue
|
||||||
|
|
||||||
|
im.seek(0)
|
||||||
|
self.assertEqual(im.size, (10,10))
|
||||||
|
self.assertEqual(im.convert('RGB').getpixel((0,0)), (0,128,0))
|
||||||
|
|
||||||
|
im.seek(1)
|
||||||
|
im.load()
|
||||||
|
self.assertEqual(im.size, (10,10))
|
||||||
|
self.assertEqual(im.convert('RGB').getpixel((0,0)), (255,0,0))
|
||||||
|
|
||||||
|
im.seek(2)
|
||||||
|
im.load()
|
||||||
|
self.assertEqual(im.size, (20,20))
|
||||||
|
self.assertEqual(im.convert('RGB').getpixel((0,0)), (0,0,255))
|
||||||
|
|
||||||
|
def test_multipage_last_frame(self):
|
||||||
|
im = Image.open('Tests/images/multipage-lastframe.tif')
|
||||||
|
im.load()
|
||||||
|
self.assertEqual(im.size, (20,20))
|
||||||
|
self.assertEqual(im.convert('RGB').getpixel((0,0)), (0,0,255))
|
||||||
|
|
||||||
|
|
||||||
def test___str__(self):
|
def test___str__(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
file = "Tests/images/pil136.tiff"
|
file = "Tests/images/pil136.tiff"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user