Converting from PDF to JPG

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
Rocinant
Posts: 3
Joined: 2011-02-28T13:15:35-07:00
Authentication code: 8675308

Converting from PDF to JPG

Post by Rocinant »

I am trying to convert a PDF file to a JPG file using the following code:

Code: Select all

<?php
exec("convert -density 100 -colorspace rgb test.pdf -scale 200x200 test.jpg");
?>
but this doesn't do anything. Converting JPG to PDF files or PNG to PDF files is no problem...
The Imagemagick version I am using is ImageMagick 6.2.8 08/03/06 Q16
The Ghostscript version is GNU Ghostscript 7.07 (2003-05-17)
Running on a Unix server

I sincerely hope somebody can help me!
Thanks in advance!
Regards,
Rocinant
geep999
Posts: 17
Joined: 2010-12-10T07:33:21-07:00
Authentication code: 8675308

Re: Converting from PDF to JPG

Post by geep999 »

Hi,
Don't know about the php bit, but I can confirm that from a command line:

Code: Select all

convert -density 100 -colorspace rgb test.pdf -scale 200x200 test.jpg
works OK for me with gs 9.00, ImageMagick 6.6.6-9
Do you see any useful messages if you run it from a command line?
Cheers,
Peter
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Converting from PDF to JPG

Post by anthony »

probably a stupid question but have to tested that "convert" is working from PHP and that you can get images out of it?

http://www.imagemagick.org/Usage/api/#php
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting from PDF to JPG

Post by fmw42 »

Your 6.2.8 version of IM is ancient (over 400 versions old) as is your Ghostscript. Perhaps you should upgrade if you can.
Rocinant
Posts: 3
Joined: 2011-02-28T13:15:35-07:00
Authentication code: 8675308

Re: Converting from PDF to JPG

Post by Rocinant »

My kind provider has updated the ImageMagick version. GNU Ghostscript 7.07 is the latest GNU version of Ghostscript. Now, if I use the commands

Code: Select all

convert test.pdf test.jpg
or

Code: Select all

gs -sDEVICE=jpg -sOutputFile=test.jpg test.pdf
I get the following error message:
GNU Ghostscript 7.07: Can't find initialization file gs_init.ps

...
What could that be?

Kind regards,
Rocinant
Rocinant
Posts: 3
Joined: 2011-02-28T13:15:35-07:00
Authentication code: 8675308

Re: Converting from PDF to JPG

Post by Rocinant »

The last problem, about the missing gs_init.ps seemed to be a directory with the wrong chmod-settings. After my provider solved that, it worked great.

Thank you all for you help!
Rocinant
Post Reply