Skip to content

EPS Image conversion fails after upgrading to 11.2.1 / 11.3.0 from 10.4.0 #9210

Description

@KrokoNinja

What did you do?

In our company we use Pillow 11.2.1 to convert EPS images to JPG and faced issues with some of the EPS files.
When i tried it locally with Pillow 10.4.0 the conversion worked fine.
As soon as i upgraded to Pillow 11.3.0 the conversion also failed on my local environment.

What did you expect to happen?

Expected output is an .jpg image from an input .eps file

What actually happened?

Our script fails as soon as it hits the "with (Image.open(inFile) as im):"

Error:
"path/to/image.eps" : cannot identify image file "path/to/image.eps"

What are your OS, Python and Pillow versions?

  • OS: Windows 11 (local) / Windows 10 (company)
  • Python: 3.12.0
  • Pillow: 11.2.1 / 11.3.0
Please paste here the output of running:

python3 -m PIL.report
--------------------------------------------------------------------
Pillow 11.3.0
Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)]
--------------------------------------------------------------------
Python executable is C:\Entwicklung\airflow\.venv\Scripts\python.exe
Environment Python files loaded from C:\Entwicklung\airflow\.venv
System Python files loaded from C:\Program Files\Python312
--------------------------------------------------------------------
Python Pillow modules loaded from C:\Entwicklung\airflow\.venv\Lib\site-packages\PIL
Binary Pillow modules loaded from C:\Entwicklung\airflow\.venv\Lib\site-packages\PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 11.3.0
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.13.3
--- LITTLECMS2 support ok, loaded 2.17
--- WEBP support ok, loaded 1.5.0
--- AVIF support ok, loaded 1.3.0
--- JPEG support ok, compiled for libjpeg-turbo 3.1.1
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.3
--- ZLIB (PNG/ZIP) support ok, loaded 1.3.1.zlib-ng, compiled for zlib-ng 2.2.4
--- LIBTIFF support ok, loaded 4.7.0
*** RAQM (Bidirectional Text) support not installed
*** LIBIMAGEQUANT (Quantization method) support not installed
*** XCB (X protocol) support not installed
--------------------------------------------------------------------

Unfortunately i cannot provide any image the script is failing on because of company terms.

with (Image.open(inFile) as im):

            # keep original size
            imWidth, imHeight = im.size
            outFileSize = (imWidth, imHeight)

            # handle images with transparency
            # and replace transparency by white background
            if (im.mode in ("RGBA", "P")):
                newImage = Image.new("RGBA", im.size, "white")
                newImage.paste(im, (0, 0), im)

                # save final file
                newImage = newImage.convert('RGB')
                newImage = ImageOps.pad(newImage, centering=(0.5, 0.5), color="white", size=outFileSize)
                newImage.save(outFile, quality=87)
            else:
                newImage = ImageOps.pad(im, centering=(0.5, 0.5), color=getColor(im), size=outFileSize)
                newImage.save(outFile, quality=87)

Activity

  1. radarhere commented on Sep 18, 2025

    @radarhere
    Member

    Without an image to directly test on, this might not be a simple process.

    Could you run this code and provide the traceback? It should provide a more specific error.

    from PIL import EpsImagePlugin
    EpsImagePlugin.EpsImageFile(inFile)
  2. KrokoNinja commented on Sep 18, 2025

    @KrokoNinja
    Author

    Seems like the file is corrupted...

    Traceback (most recent call last):
      File "xxx", line 5, in <module>
        EpsImagePlugin.EpsImageFile(inFile)
      File "xxx\Lib\site-packages\PIL\ImageFile.py", line 147, in __init__
        self._open()
      File "xxx\Lib\site-packages\PIL\EpsImagePlugin.py", line 272, in _open
        raise SyntaxError(msg)
    SyntaxError: not an EPS file
  3. radarhere commented on Sep 18, 2025

    @radarhere
    Member

    Thanks. So the error from that line occurs because there is an EPS comment that is longer than 255 characters.

    # ASCII/hexadecimal lines in an EPS file must not exceed
    # 255 characters, not including line ending characters
    if bytes_read >= 255:
    # only enforce this for lines starting with a "%",
    # otherwise assume it's binary data
    if byte_arr[0] == ord("%"):
    msg = "not an EPS file"
    raise SyntaxError(msg)

    The strange part is that isn't immediately obvious why that wouldn't have failed for you in 10.4.0.

    Could you test Pillow 11.0.0 and 11.1.0 to see exactly which Pillow version the failure starts with?

  4. KrokoNinja commented on Sep 18, 2025

    @KrokoNinja
    Author

    11.0.0 and 11.1.0 are also not working...
    I tried also again with 10.4.0 and there its working.
    So with our files its:
    11.3.0 - 11.0.0 => not working
    10.4.0 => working

  5. KrokoNinja commented on Sep 18, 2025

    @KrokoNinja
    Author

    Talked to my boss and got a .eps which I'm allowed to share with you.
    Had to zip it because eps is not supported on github.

    testEPS.zip

  6. radarhere commented on Sep 18, 2025

    @radarhere
    Member

    Thanks very much.

    #8281 was change in behaviour. https://github.com/python-pillow/Pillow/pull/8281/files#diff-c43e9ae25942c60787ebabdbfabddf8618c31d166f93520ea22c8547957f7e9eL337 meant that previously, Pillow stopped reading once the image data was found. Now, it continues reading, encounters "%%BeginBinary", and mistakes some of the data inside for a comment.

    If you want an immediate solution, without waiting for a PR and a Pillow release, you could just trim it from the data that Pillow receives.

    from PIL import Image
    from io import BytesIO
    with open("test.eps", "rb") as fp:
    	b = BytesIO(fp.read().split(b"%%BeginBinary")[0])
    	im = Image.open(b)
  7. KrokoNinja commented on Sep 18, 2025

    @KrokoNinja
    Author

    Thanks for the explanation I will take this to the team and we will find a solution until the PR goes throught 😄
    Thank you for your fast help ❤️

  8. radarhere commented on Sep 18, 2025

    @radarhere
    Member

    I've created #9211 to resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions