Page 1 of 1
convert pdf to jpg
Posted: 2007-02-05T14:34:50-07:00
by ayahuasca
Hello,
i am trying to convert pdf files (or 1 page of a pdf file) to jpg to make a previeuw of the pdf availeble.
I am doing this with ImageMagick and Ghostscript.
When i do this in a cmd on my windows server it works perfectly.
When i try to do it in a php file it does not do anything.
the command i am using is this:
<?
exec("convert 1.pdf[0] 1.jpg");
?>
could somebody please tel me what i am doing wrong?
Re: convert pdf to jpg
Posted: 2007-02-05T15:41:48-07:00
by Bonzo
I have not used pdf but as far as I can tell you are trying to convert layer 0 to a jpg ?
Have you tried:
Re: convert pdf to jpg
Posted: 2007-02-06T03:23:09-07:00
by ayahuasca
Yes i have tried it, doesn't work.
What i am doing is convert page 1 of the pdf to jpg.
I am wondering if exec() does work. Is there mayby a simpel command to check if exec does anything?
Re: convert pdf to jpg
Posted: 2007-02-06T08:30:24-07:00
by ayahuasca
Problem solved.
The big secret is to restart your server after completing the installation script of ImageMagick and Ghostscript!
Anywayz, Thanks for trying...
Re: convert pdf to jpg
Posted: 2007-02-07T11:05:16-07:00
by ridera
I'm working on the same thing, trying to get a thumbnail of the first page to show. I'm posting another topic especially for it.
However, as to your problem: add "-debug exception" to your command; it'll show you what's going on. A typical command, with debug looks like this:
$command= "/usr/local/bin/convert -debug exception $precomm $fpfile $comm $tb_fpfile";
exec($command, $convert_array, $code); Note the $convert_array; that's where your debug message is
My guess is that path to "convert" is not correct.
Re: convert pdf to jpg
Posted: 2007-03-27T08:46:45-07:00
by pieter
I had the same problem. I solved it by replacing the exec() command by the popen() function. Maybe this will be your solution as wel.. Good luck!