Merge pull request #1152 from hugovk/1104

Fix: Cannot identify EPS images
This commit is contained in:
Alex Clark 2015-03-31 21:12:55 -04:00
commit 0925c4adbb
6 changed files with 17 additions and 2 deletions

View File

@ -275,13 +275,13 @@ class EpsImageFile(ImageFile.ImageFile):
s = fp.readline().strip('\r\n') s = fp.readline().strip('\r\n')
if s[0] != "%": if s[:1] != "%":
break break
# #
# Scan for an "ImageData" descriptor # Scan for an "ImageData" descriptor
while s[0] == "%": while s[:1] == "%":
if len(s) > 255: if len(s) > 255:
raise SyntaxError("not an EPS file") raise SyntaxError("not an EPS file")

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -223,6 +223,21 @@ class TestFileEps(PillowTestCase):
self._test_readline_file_psfile(s, ending) self._test_readline_file_psfile(s, ending)
def test_open_eps(self):
# https://github.com/python-pillow/Pillow/issues/1104
# Arrange
FILES = ["Tests/images/illu10_no_preview.eps",
"Tests/images/illu10_preview.eps",
"Tests/images/illuCS6_no_preview.eps",
"Tests/images/illuCS6_preview.eps"]
# Act
for filename in FILES:
img = Image.open(filename)
# Assert
self.assertEqual(img.mode, "RGB")
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()