EPS to JPG - some work, some don't? Why?

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
cranky

EPS to JPG - some work, some don't? Why?

Post by cranky » 2008-10-30T12:38:23-07:00

Hi All,

I have run into this problem and it is driving me a little crazy.

I am trying to convert EPS images to JPG. I am using this code:

Code: Select all

$blob = file_get_contents("test.eps");
$magick_wand=NewMagickWand();
MagickReadImageBlob($magick_wand, $blob);
$wand = NewMagickWand();
MagickSetResolution( $wand, 300, 300 );
MagickReadImageBlob($wand, $blob);
$new_wand = MagickTransformImage($wand, NULL, '3000x');
MagickSetImageFormat($new_wand, 'jpg') ;
MagickWriteImage($new_wand, "file.jpg");
DestroyMagickWand($new_wand);
DestroyMagickWand($wand);
For the most part, this works great with all my test files. However, someone recently began uploading their EPS files and they all failed. I looked into it, and here is what I found:

1) With my EPS files, Unix shows them as having a 'application/octet-stream' mime type. The problem EPS files seem to have a mime of 'application/postscript'.

2) The problem files will not work with MagickReadImageBlob. The script stops there. They will only work with MagickReadImage.
Inversely, my original test images only seem to work with MagickReadImageBlob.

3) Finally, even when using MagickReadImage, the output for the problems images is a blank white jpg image.

I can not see anything noticeably wrong or different with the files, but clearly there is something causing this trouble. Any ideas or suggestions? I am completely stumped.

Thanks!

User avatar
magick
Site Admin
Posts: 11039
Joined: 2003-05-31T11:32:55-07:00

Re: EPS to JPG - some work, some don't? Why?

Post by magick » 2008-10-30T13:12:20-07:00

Its possible ImageMagick is choking on certain types of Postscript image files. Post a URL to one that you know does not render properly and we will try to reproduce the problem and offer a solution.

cranky

Re: EPS to JPG - some work, some don't? Why?

Post by cranky » 2008-10-30T13:46:53-07:00

You've got mail :)

User avatar
magick
Site Admin
Posts: 11039
Joined: 2003-05-31T11:32:55-07:00

Re: EPS to JPG - some work, some don't? Why?

Post by magick » 2008-10-30T16:39:57-07:00

ImageMagick utilizes the Ghostscript delegate library or program to render Postscript. Your image is in the Adobe Illustrator format and Ghostscript chokes on it it. We're using GPL Ghostscript 8.63. Its possible a recent version of Ghostscript may correctly interpret your Postscript file otherwise post a bug report to the Ghostscript mailing list. To verify, type
  • gs scruffy-cats004.eps
Its also possible the Postscript is corrupt.

cranky

Re: EPS to JPG - some work, some don't? Why?

Post by cranky » 2008-10-30T19:45:09-07:00

Thanks for the help! Yes, there does appear to be a problem from the Ghost Script and of things. Is this about what you were expecting to see, to indicate a problem on GhostScript's end of things?

From your expertise with ImageMagick, do you think this has any apparent correlation with why MagickReadImageBlob() did not work with the image? I am wondering if any of my previous observations have any correlation with the actual problem, now that we know roughly what it is.

Thanks!

Code: Select all

[root@Server6482 temp]# gs scruffy-cats004.eps
GNU Ghostscript 7.07 (2003-05-17)
Copyright (C) 2003 artofcode LLC, Benicia, CA.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimbusRomNo9L-Regu font from /usr/share/fonts/default/Type1/n021003l.pfb... 2469820 1099972 1642520 351150 0 done.
Using NimbusRomanNo9L-Regu font for NimbusRomNo9L-Regu.
Loading NimbusSanL-Regu font from /usr/share/fonts/default/Type1/n019003l.pfb... 2844780 1444610 1682712 365686 0 done.
Using NimbusSansL-Regu font for NimbusSanL-Regu.
Error: /undefined in Adobe_level2_AI5
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1060/1123(ro)(G)--   --dict:0/20(G)--   --dict:88/200(L)--
Current allocation mode is local
Current file position is 1197
GNU Ghostscript 7.07: Unrecoverable error, exit code 1

cranky

Re: EPS to JPG - some work, some don't? Why?

Post by cranky » 2008-11-14T08:48:19-07:00

To update this page, in case someone else comes across the issue - this is a known problem via Ghost Script. However, the problem is caused by when someone uses an EPS file that is created only for Illustrator. These files do not have the embedded information that is required to be even opened by Photoshop, and also can not be opened by Ghost Script. They are basically locked to Illustrator.

There is no currently solution, except to have the user re-save the EPS with full permissions included.

Hope that helps someone down the road.

Post Reply