Merge pull request #2447 from hugovk/test-mic

Test MicImagePlugin for correctness
This commit is contained in:
wiredfool 2017-06-13 22:20:44 +01:00 committed by GitHub
commit 8323ab1149
9 changed files with 47 additions and 9 deletions

View File

@ -97,6 +97,7 @@ class MicImageFile(TiffImagePlugin.TiffImageFile):
return self.frame
#
# --------------------------------------------------------------------

BIN
Tests/images/hopper.mic Normal file

Binary file not shown.

View File

@ -2,7 +2,6 @@ from helper import unittest, PillowTestCase
from PIL import Image, FliImagePlugin
# sample ppm stream
# created as an export of a palette image from Gimp2.6
# save as...-> hopper.fli, default options.
test_file = "Tests/images/hopper.fli"

View File

@ -3,7 +3,6 @@ from helper import unittest, PillowTestCase, hopper
import io
from PIL import Image, IcoImagePlugin
# sample ppm stream
TEST_ICO_FILE = "Tests/images/hopper.ico"

View File

@ -1,10 +1,50 @@
from helper import unittest, PillowTestCase
from helper import unittest, PillowTestCase, hopper
from PIL import MicImagePlugin
from PIL import Image, ImagePalette, MicImagePlugin
TEST_FILE = "Tests/images/hopper.mic"
class TestFileMic(PillowTestCase):
def test_sanity(self):
im = Image.open(TEST_FILE)
im.load()
self.assertEqual(im.mode, "RGBA")
self.assertEqual(im.size, (128, 128))
self.assertEqual(im.format, "MIC")
# Adjust for the gamma of 2.2 encoded into the file
lut = ImagePalette.make_gamma_lut(1/2.2)
im = Image.merge('RGBA', [chan.point(lut) for chan in im.split()])
im2 = hopper("RGBA")
self.assert_image_similar(im, im2, 10)
def test_n_frames(self):
im = Image.open(TEST_FILE)
self.assertEqual(im.n_frames, 1)
def test_is_animated(self):
im = Image.open(TEST_FILE)
self.assertFalse(im.is_animated)
def test_tell(self):
im = Image.open(TEST_FILE)
self.assertEqual(im.tell(), 0)
def test_seek(self):
im = Image.open(TEST_FILE)
im.seek(0)
self.assertEqual(im.tell(), 0)
self.assertRaises(EOFError, lambda: im.seek(99))
self.assertEqual(im.tell(), 0)
def test_invalid_file(self):
# Test an invalid OLE file
invalid_file = "Tests/images/flower.jpg"

View File

@ -2,11 +2,10 @@ from helper import hopper, unittest, PillowTestCase
from PIL import Image, PixarImagePlugin
# sample ppm stream
TEST_FILE = "Tests/images/hopper.pxr"
class TestImagePsd(PillowTestCase):
class TestFilePixar(PillowTestCase):
def test_sanity(self):
im = Image.open(TEST_FILE)

View File

@ -2,7 +2,6 @@ from helper import hopper, unittest, PillowTestCase
from PIL import Image, PsdImagePlugin
# sample ppm stream
test_file = "Tests/images/hopper.psd"

View File

@ -2,7 +2,6 @@ from helper import unittest, PillowTestCase, hopper
from PIL import Image, XpmImagePlugin
# sample ppm stream
TEST_FILE = "Tests/images/hopper.xpm"

View File

@ -789,6 +789,8 @@ PIL identifies and reads Microsoft Image Composer (MIC) files. When opened, the
first sprite in the file is loaded. You can use :py:meth:`~file.seek` and
:py:meth:`~file.tell` to read other sprites from the file.
Note that there may be an embedded gamma of 2.2 in MIC files.
MPO
^^^