Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some EPS file not handled correctly #302

Closed
lmazuel opened this issue Jul 25, 2013 · 4 comments
Closed

Some EPS file not handled correctly #302

lmazuel opened this issue Jul 25, 2013 · 4 comments
Milestone

Comments

@lmazuel
Copy link

lmazuel commented Jul 25, 2013

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 :-)

@aclark4life
Copy link
Member

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

@aclark4life
Copy link
Member

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

@lmazuel
Copy link
Author

lmazuel commented Oct 11, 2013

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"...

eliempje added a commit to eliempje/Pillow that referenced this issue May 7, 2014
FIXED issue python-pillow#302: python-pillow#302
EPS file can have binary preview. Header is now also read binary.

Also fix for resizing EPS. Resolution is now 2 dimensional and dependend on bbox and size.
eliempje added a commit to eliempje/Pillow that referenced this issue May 14, 2014
@wiredfool
Copy link
Member

Fixed in #619

radarhere pushed a commit to radarhere/Pillow that referenced this issue Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants