diff --git a/PIL/PixarImagePlugin.py b/PIL/PixarImagePlugin.py index 732d8c692..220577cce 100644 --- a/PIL/PixarImagePlugin.py +++ b/PIL/PixarImagePlugin.py @@ -24,6 +24,7 @@ from ._binary import i16le as i16 __version__ = "0.1" + # # helpers @@ -61,6 +62,7 @@ class PixarImageFile(ImageFile.ImageFile): # create tile descriptor (assuming "dumped") self.tile = [("raw", (0, 0)+self.size, 1024, (self.mode, 0, 1))] + # # -------------------------------------------------------------------- diff --git a/Tests/images/hopper.pxr b/Tests/images/hopper.pxr new file mode 100644 index 000000000..a7dee295a Binary files /dev/null and b/Tests/images/hopper.pxr differ diff --git a/Tests/test_file_pixar.py b/Tests/test_file_pixar.py new file mode 100644 index 000000000..3078b438b --- /dev/null +++ b/Tests/test_file_pixar.py @@ -0,0 +1,30 @@ +from helper import hopper, unittest, PillowTestCase + +from PIL import Image, PixarImagePlugin + +# sample ppm stream +TEST_FILE = "Tests/images/hopper.pxr" + + +class TestImagePsd(PillowTestCase): + + def test_sanity(self): + im = Image.open(TEST_FILE) + im.load() + self.assertEqual(im.mode, "RGB") + self.assertEqual(im.size, (128, 128)) + self.assertEqual(im.format, "PIXAR") + + im2 = hopper() + self.assert_image_similar(im, im2, 4.8) + + def test_invalid_file(self): + invalid_file = "Tests/images/flower.jpg" + + self.assertRaises( + SyntaxError, + lambda: PixarImagePlugin.PixarImageFile(invalid_file)) + + +if __name__ == '__main__': + unittest.main()