Merge pull request #1846 from wiredfool/pr_1826

EPS + CMYK
This commit is contained in:
wiredfool 2016-06-30 15:23:24 +01:00 committed by GitHub
commit 872fd0652e
4 changed files with 21 additions and 2 deletions

View File

@ -201,7 +201,7 @@ class EpsImageFile(ImageFile.ImageFile):
format = "EPS"
format_description = "Encapsulated Postscript"
mode_map = {1: "L", 2: "LAB", 3: "RGB"}
mode_map = {1: "L", 2: "LAB", 3: "RGB", 4: "CMYK"}
def _open(self):
(length, offset) = self._find_offset(self.fp)

Binary file not shown.

View File

@ -57,6 +57,21 @@ class TestFileEps(PillowTestCase):
self.assertRaises(SyntaxError,
lambda: EpsImagePlugin.EpsImageFile(invalid_file))
def test_cmyk(self):
cmyk_image = Image.open("Tests/images/pil_sample_cmyk.eps")
self.assertEqual(cmyk_image.mode, "CMYK")
self.assertEqual(cmyk_image.size, (100, 100))
self.assertEqual(cmyk_image.format, "EPS")
cmyk_image.load()
self.assertEqual(cmyk_image.mode, "RGB")
if 'jpeg_decoder' in dir(Image.core):
target = Image.open('Tests/images/pil_sample_rgb.jpg')
self.assert_image_similar(cmyk_image, target, 10)
def test_file_object(self):
# issue 479
image1 = Image.open(file1)

View File

@ -34,7 +34,11 @@ EPS
PIL identifies EPS files containing image data, and can read files that contain
embedded raster images (ImageData descriptors). If Ghostscript is available,
other EPS files can be read as well. The EPS driver can also write EPS images.
other EPS files can be read as well. The EPS driver can also write EPS
images. The EPS driver can read EPS images in ``L``, ``LAB``, ``RGB`` and
``CMYK`` mode, but Ghostscript may convert the images to ``RGB`` mode rather
than leaving them in the original color space. The EPS driver can write images
in ``L``, ``RGB`` and ``CMYK`` modes.
If Ghostscript is available, you can call the :py:meth:`~PIL.Image.Image.load`
method with the following parameter to affect how Ghostscript renders the EPS