Skip to content

Some EPS file not handled correctly #302

Description

@lmazuel

Hi all,

I try to use Pillow in Py3.3 with EPS file.

First of all, all my test are made with this basic EPS file:
test
(download and rename the extension to EPS, Github does not allow eps directly and I hack it using Png extension :-p)

Many problems:

  • This is a kind of EPS which begins by "0xC6D3D0C5". Currently, this kind of EPS cannot work in Python 3 because of this:
        s = fp.read(512)
        if s[:4] == b"%!PS":
            offset = 0
            fp.seek(0, 2)
            length = fp.tell()
        elif i32(s) == 0xC6D3D0C5:

And the PSfile implementation of read is:

    def read(self, count):
        return self.fp.read(count).decode('latin-1')

And "i32" raises TypeError in this case.

I think it is a bad idea to decode as a string here, moreover using latin-1 (at worst ascii). Sometimes EPS files can contain only ascii, but sometimes they contain binary data which will be not compatible with latin-1 conversion.

I have tried to fix converting all "str" to "bytes" (and the parsing is now OK), but I'm not sure this is compatible with Python 2 users...

Moreover, I'm not able to save it... The "length" read here:

        elif i32(s) == 0xC6D3D0C5:
            offset = i32(s[4:])
            length = i32(s[8:])
            fp.seek(offset)

is too small, and the loop inside "Ghoscript" function leads to a bad exit code while running "gs".... I don't known the EPS norm and I block at this point...

If someone is curious about correcting the EPS module :-)

Activity

  1. aclark4life commented on Jul 25, 2013

    @aclark4life
    Member

    Interesting, thanks. Maybe send a pull request for your Python 3 fix and we'll see what we can do for Python 2

  2. aclark4life commented on Sep 27, 2013

    @aclark4life
    Member

    If you don't get an answer here please try asking on StackOverflow e.g. http://stackoverflow.com/questions/tagged/python-imaging-library

  3. lmazuel commented on Oct 11, 2013

    @lmazuel
    Author

    I have tested yesterday with the "wand" Py3 wrapper of ImageMagick and it successfully does the job. I think I will be pragmatic and switch to "wand"...

  4. added a commit that references this issue on May 7, 2014
  5. wiredfool commented on May 24, 2014

    @wiredfool
    Member

    Fixed in #619

  6. added a commit that references this issue on Sep 24, 2023
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions