Convert PDF to JPG/GIF

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
bwacjay

Convert PDF to JPG/GIF

Post by bwacjay »

I'm having repeated issues converting PDF's with transparency to any raster format, which I have attributed to problems that Ghostscript has with PDF transparency.

However, I've uncovered a new problem that seems to me to be related to IM, not GS, and I'm looking for some explanation of what's going on.

This PDF file: http://drop.io/8mfemel is a PDF created in InDesign CS3, exported to PDF, and form fields added in Acrobat 8. The original INDD file has some graphics that contain transparency.

When I use straight Ghostscript (through GSView 4.9 and Ghostscript 8.61) to convert the PDF file to JPG, I get a good rendering of the file, as shown here: http://bwacm.imagick.s3.amazonaws.com/s ... orrect.jpg

However, when I use IM (6.3.7) to do a 'convert spring.pdf spring.jpg' I get a bad rendering as shown here: http://bwacm.imagick.s3.amazonaws.com/s ... roblem.jpg . I have also tried 'convert -alpha on spring.pdf spring.jpg' with the same results.

I understand that JPG doesn't support transparency, but the problem is also identically visible when converting to a GIF, and all the transparency in the INDD file should have been flattened before exporting. I get a couple errors when running the IM command, but they are related to fonts not being embedded, and I'm pretty sure this is unrelated.

Any explanation on why I'm getting different results from GS and IM (which passes all PDf related renderings directly to GS, as I understand it) would be greatly appreciated.

Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert PDF to JPG/GIF

Post by fmw42 »

Actually I have no idea what is really going on, but have you tried to upgrade to the latest version of IM 6.3.9-x. The folks at IM are constantly improving things and perhaps there was some change made recently that has fixed an issue with the use of Ghostscript.

You might also search the archives here to see if there was any reported issue or upgrade regarding Ghostscript
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Convert PDF to JPG/GIF

Post by magick »

We're using Ghostscript 8.61 and ImageMagick 6.3.9. With this command we get the expected results:
  • convert -colorspace rgb spring.pdf spring.jpg
bwacjay

Re: Convert PDF to JPG/GIF

Post by bwacjay »

Thanks for the help. I didn't realize that the version I was using wasn't current -- I just installed it about a month ago, I think.

I'll update the version, run the recommended command and see what results I get. It'll be later today before I can get to it, then I'll post the results.

Thanks again for the help!
bwacjay

Re: Convert PDF to JPG/GIF

Post by bwacjay »

I updated the version of IM with the same results. However, I used the -colorspace rgb option and it worked perfectly on my local box. Maybe this was the problem all along.

I'll make the change in my webapp and see if the results are improved there as well.

Thanks for your suggestions. Any ideas why using the colorspace option would elminate this problem? I do not have a great working knowledge of colorspace except that it's supposed to help match colors more closely which is not my problem here...

Thanks again,
Jay
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Convert PDF to JPG/GIF

Post by anthony »

The -colorspace is a 'hack' to give IM a clue about how to handle ghostscript. See IM examples, Common Formats, Postscript for notes about this...
http://imagemagick.org/Usage/formats/#ps

Basically it tells IM to switch to a pngalpha outptu device when using ghostscript.

IT is extremely difficult for IM to handle postscript, as it can not read and determine what a postscript "program" is attempting to do. Postscript is a full computer language, not just a image file format, and this is the reason for the problems.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply