PHP convert pdf to jpg
Posted: 2009-07-01T08:58:50-07:00
I have Win2003 server, latest Php, IIS6, GS and latest ImageMagick installed. IIS, Php and ImageMagick works fine. I try to convert .pdf file to .jpg.
I can run from command line:
C:\\Imagick\\convert -verbose -thumbnail 100 c:\\Inetpub\\wwwroot\\designbank\\testi.pdf c:\\Inetpub\\wwwroot\\designbank\\oos.jpg
Everything goes fine, the file is created and I can get verbose result:
[ghostscript library] -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -d
MaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pnmraw"
-dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=C:/DOCUME~1/ADM
INI~1/LOCALS~1/Temp/2/magick-cWHm51ww" "-fC:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/2/m
agick-MSailHAw" "-fC:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/2/magick-8I19aMvG"C:/DOCUM
E~1/ADMINI~1/LOCALS~1/Temp/2/magick-cWHm51ww PNM 612x792 612x792+0+0 8-bit Direc
tClass 1.387mb
c:\\Inetpub\\wwwroot\\designbank\\testi.pdf PDF 612x792 612x792+0+0 16-bit Direc
tClass 1.387mb
c:\\Inetpub\\wwwroot\\designbank\\testi.pdf=>c:\\Inetpub\\wwwroot\\designbank\\o
os.jpg PDF 612x792=>100x129 8-bit DirectClass 0.156u 0:01
If I try to run the same from php code, the file is not created.
PHP code:
<?php
$last_line = system("C:\\Imagick\\convert -verbose -thumbnail 100 c:\\Inetpub\\wwwroot\\designbank\\testi.pdf c:\\Inetpub\\wwwroot\\designbank\\oos.jpg", $retval);
print $last_line;
?>
Result I get:
[ghostscript library] -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=C:/WINDOWS/TEMP/magick-wabYT6WA" "-fC:/WINDOWS/TEMP/magick-qk7fpUeF" "-fC:/WINDOWS/TEMP/magick-qK8ulk6I"[ghostscript library] -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=C:/WINDOWS/TEMP/magick-wabYT6WA" "-fC:/WINDOWS/TEMP/magick-qk7fpUeF" "-fC:/WINDOWS/TEMP/magick-qK8ulk6I"
So I suppose PHP can't run the code totally. Something is missing from the end. Can someone tell me what I am missing?
Thanks.
I can run from command line:
C:\\Imagick\\convert -verbose -thumbnail 100 c:\\Inetpub\\wwwroot\\designbank\\testi.pdf c:\\Inetpub\\wwwroot\\designbank\\oos.jpg
Everything goes fine, the file is created and I can get verbose result:
[ghostscript library] -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -d
MaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pnmraw"
-dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=C:/DOCUME~1/ADM
INI~1/LOCALS~1/Temp/2/magick-cWHm51ww" "-fC:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/2/m
agick-MSailHAw" "-fC:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/2/magick-8I19aMvG"C:/DOCUM
E~1/ADMINI~1/LOCALS~1/Temp/2/magick-cWHm51ww PNM 612x792 612x792+0+0 8-bit Direc
tClass 1.387mb
c:\\Inetpub\\wwwroot\\designbank\\testi.pdf PDF 612x792 612x792+0+0 16-bit Direc
tClass 1.387mb
c:\\Inetpub\\wwwroot\\designbank\\testi.pdf=>c:\\Inetpub\\wwwroot\\designbank\\o
os.jpg PDF 612x792=>100x129 8-bit DirectClass 0.156u 0:01
If I try to run the same from php code, the file is not created.
PHP code:
<?php
$last_line = system("C:\\Imagick\\convert -verbose -thumbnail 100 c:\\Inetpub\\wwwroot\\designbank\\testi.pdf c:\\Inetpub\\wwwroot\\designbank\\oos.jpg", $retval);
print $last_line;
?>
Result I get:
[ghostscript library] -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=C:/WINDOWS/TEMP/magick-wabYT6WA" "-fC:/WINDOWS/TEMP/magick-qk7fpUeF" "-fC:/WINDOWS/TEMP/magick-qK8ulk6I"[ghostscript library] -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=C:/WINDOWS/TEMP/magick-wabYT6WA" "-fC:/WINDOWS/TEMP/magick-qk7fpUeF" "-fC:/WINDOWS/TEMP/magick-qK8ulk6I"
So I suppose PHP can't run the code totally. Something is missing from the end. Can someone tell me what I am missing?
Thanks.