Page 1 of 1

Converting from PDF to JPG

Posted: 2011-02-28T13:37:01-07:00
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

Re: Converting from PDF to JPG

Posted: 2011-02-28T14:01:49-07:00
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

Re: Converting from PDF to JPG

Posted: 2011-03-01T16:54:10-07:00
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

Re: Converting from PDF to JPG

Posted: 2011-03-01T16:56:01-07:00
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.

Re: Converting from PDF to JPG

Posted: 2011-03-03T13:55:41-07:00
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

Re: Converting from PDF to JPG

Posted: 2011-03-03T14:31:10-07:00
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