[Image-SIG] Correctly determine image size of a Photoshop EPS
stefano at pragma2000.com
Tue Sep 20 11:30:28 CEST 2005
On 9/20/05, Fredrik Lundh <fredrik at pythonware.com> wrote:
> PIL is supposed to support ImageData tags, and it should pick the size from
> the ImageData header over the bounding box, but I suppose it's not robust
> enough to handle your file.
Thanks for the hint, Fredrik. Indeed I went and looked at the code and
found the reason:
EpsImagePlugin.py around line 237.
After reading ImageData, before setting self.size to the according
values, it tries to determine the decoder type. According to the
specification, even the one I posted previously, the only supported
values are 1 and 2 (binary and hex, respectively). But in my case,
there's a value of 6. At this point the code exits with a break, and
doesn't reach the point where it sets the size.
So, I guess a quick fix would be to move the self.size = x,y code a
little upper, but maybe there's a reason this should not be done, I
By the way, I experimentally found out what the various values mean,
by generating different eps files with Photoshop. Here's the list:
1 - binary
2 - ascii
3 - jpeg low quality
4 - jpeg medium quality
5 - jpeg high quality
6 - jpeg maximum quality
7 - ascii85
These correspond to the options you get in the save dialog in Photoshop.
Actually, I'm not sure what use you make with this information, since
it's ghostscript's job to convert the file to ppmraw format, and I
found no other reference in PIL's code to the above decoder type,
except for self.tile2, which is not referenced anywhere as well.
Furthermore, as I already noticed on another image previously (that I
think I wrote to you about), pil can't get ghostscript to successfully
process the file, and doesn't generate any output. I don't know why is
that, but I was able to successfully convert it with imagemagick, that
uses ghostscript too, so I figured there's got to be some way to do
it. I just don't know enough ghostscript to fix pil and make it work!
> if you can mail me a copy of the file (off-list), I can take a look when I find
> the time.
I will, thanks!
More information about the Image-SIG