PDF to JPG not working from php front end
PDF to JPG not working from php front end
PDF to JPG not working from php front end
It works fine on command line using
convert test.pdf test123.jpg
the path for both are /usr/bin/convert and /usr/bin/gs
versions are
imagemagick 6.5.4-7
ghostscript 8.70
I have tried this code and a couple of others from the web
<?php
Replace input.jpg with the name of a jpg image in the same folder as this code and run it.
exec("/usr/bin/convert test.pdf jastest123.jpg");
?>
it convert from jpg to pdf but not pdf to jpg
any help would be appreciated
thanks
It works fine on command line using
convert test.pdf test123.jpg
the path for both are /usr/bin/convert and /usr/bin/gs
versions are
imagemagick 6.5.4-7
ghostscript 8.70
I have tried this code and a couple of others from the web
<?php
Replace input.jpg with the name of a jpg image in the same folder as this code and run it.
exec("/usr/bin/convert test.pdf jastest123.jpg");
?>
it convert from jpg to pdf but not pdf to jpg
any help would be appreciated
thanks
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: PDF to JPG not working from php front end
Converting from pdf to jpg needs ghostscript. This will be a configuration problem with php. I don't know the answer, but it will be on these forums somewhere.
snibgo's IM pages: im.snibgo.com
Re: PDF to JPG not working from php front end
Yes i have ghostscript installed and it works on command line
all i have read is they need the same path e.g. /usr/bin/
/usr/bin/convert
/usr/bin/gs
but how to I make it work on php
I even tried this from http://www.veryinteractivepeople.com/?p=521
but nothing happens
<?php
ini_set('display_errors', 1);
$pdf='test.pdf';
$quality=90;
$res='300x300';
$exportName="pdf_export_" . time();
$exportPath=realpath(dirname(__FILE__))."/$exportName/fullres/%03d.jpg";
mkdir(realpath(dirname(__FILE__))."/$exportName");
mkdir(realpath(dirname(__FILE__))."/$exportName/fullres");
set_time_limit(900);
exec("'gs' '-dNOPAUSE' '-sDEVICE=jpeg' '-dUseCIEColor' '-dTextAlphaBits=4' '-dGraphicsAlphaBits=4' '-o$exportPath' '-r$res' '-dJPEGQ=$quality' '$pdf'",$output);
for($i=0;$i<count($output);$i++)
echo($output[$i] .'<br/>');
?>
but what else?
thanks
all i have read is they need the same path e.g. /usr/bin/
/usr/bin/convert
/usr/bin/gs
but how to I make it work on php
I even tried this from http://www.veryinteractivepeople.com/?p=521
but nothing happens
<?php
ini_set('display_errors', 1);
$pdf='test.pdf';
$quality=90;
$res='300x300';
$exportName="pdf_export_" . time();
$exportPath=realpath(dirname(__FILE__))."/$exportName/fullres/%03d.jpg";
mkdir(realpath(dirname(__FILE__))."/$exportName");
mkdir(realpath(dirname(__FILE__))."/$exportName/fullres");
set_time_limit(900);
exec("'gs' '-dNOPAUSE' '-sDEVICE=jpeg' '-dUseCIEColor' '-dTextAlphaBits=4' '-dGraphicsAlphaBits=4' '-o$exportPath' '-r$res' '-dJPEGQ=$quality' '$pdf'",$output);
for($i=0;$i<count($output);$i++)
echo($output[$i] .'<br/>');
?>
but what else?
thanks
Re: PDF to JPG not working from php front end
how can I call ghostscript directly
exec("/usr/bin/convert test.pdf jastest123.jpg");
for e.g for gs
exec("/usr/bin/gs test.pdf jastest123.jpg");
exec("/usr/bin/convert test.pdf jastest123.jpg");
for e.g for gs
exec("/usr/bin/gs test.pdf jastest123.jpg");
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PDF to JPG not working from php front end
Your PHP probably does not find Ghostscript
Re: PDF to JPG not working from php front end
so how can I fix this? any suggestions
thanks
thanks
Re: PDF to JPG not working from php front end
if i run
convert -list configure
I can see gs under delegates along with freetype fontconfig etc
so that means imagemagick see's gs?
convert -list configure
I can see gs under delegates along with freetype fontconfig etc
so that means imagemagick see's gs?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PDF to JPG not working from php front end
I think your PHP configuration needs to point to GS or at least a version of IM that knows about GS. Search the forum. There may have been topics about this before.
Re: PDF to JPG not working from php front end
if I can see gs under delegates doesnt that mean IM knows about gs?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: PDF to JPG not working from php front end
No. It means it wants GS.
snibgo's IM pages: im.snibgo.com
Re: PDF to JPG not working from php front end
ok so how do I add it? should I un install both and reinstall? or do just IM only
thanks
thanks
Re: PDF to JPG not working from php front end
If you can uninstall and reinstall I would; I believe Ghostscript should be installed first.
Re: PDF to JPG not working from php front end
it was a pain to even get this far - is it possible i can add the path to the delegates.xml? where would it be? if I can get the ssh command that would be kool
thanks for you help
thanks for you help
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PDF to JPG not working from php front end
If you see gs under delegates from convert -version or convert -list configure, then Imagemagick should be seeing it. That is why it works under the terminal. The problem, I think, is that PHP is not finding it for use with Imagickdanfar wrote:if I can see gs under delegates doesnt that mean IM knows about gs?
Re: PDF to JPG not working from php front end
so this guy is wrong
Postby snibgo » 2014-12-08T15:58:51-05:00
No. It means it wants GS ??
how do I fix it??
can i pay someone to fix this?
Postby snibgo » 2014-12-08T15:58:51-05:00
No. It means it wants GS ??
how do I fix it??
can i pay someone to fix this?