ghostscript在php中不起作用 [英] ghostscript not working in php
问题描述
我想创建将pdf文件的第一页转换为jpg图像的php页面. 我有这些代码.
I want to create php page which convert first page of pdf file to jpg image. I have these code.
exec('convert -density 300"24.pdf" [0]"24-1.jpg"',$ output); print_r(array_values($ output));
exec('convert -density 300 "24.pdf"[0] "24-1.jpg"', $output); print_r(array_values($output));
它不起作用. 我已经测试了以下代码(带有命令提示符和php),并且运行良好. Exec('DIR',$ output); print_r(array_values($ output)); //检查命令
It not work. I have tested following code(with command prompt and php) and it works well. Exec('DIR', $output); print_r(array_values($output)); //to check command
Exec('convert',$ output); print_r(array_values($ output)); //检查imageMagick
Exec('convert', $output); print_r(array_values($output)); //to check imageMagick
Exec('convert -transverse 22.jpg 22-1.jpg',$ output); print_r(array_values($ output)); //检查imageMagick函数
Exec('convert -transverse 22.jpg 22-1.jpg', $output); print_r(array_values($output)); //to check imageMagick function
但是当我尝试此命令时
Exec('convert -transverse 22.pdf [0] 22-1.jpg',$ output); print_r(array_values($ output)); //使用pdf检查imageMagick函数
Exec('convert -transverse 22.pdf[0] 22-1.jpg',$output); print_r(array_values($output)); //to check imageMagick function with pdf
它不起作用,但以上所有命令均与命令提示符一起起作用. 看来imageMagik运作良好,但ghostscript却有php问题. 请您告诉我为什么ghostscript无法与php一起使用.
It not work but all above command is working with command prompt. It seems that imageMagik working well but ghostscript have problem with php. Please can you tell me why ghostscript is not working with php.
我正在使用 Window 7 Ultimate,IIS7.5和PHP 5.3. ImageMagick-6.8.7-Q16 幽灵脚本9.10
I'm using Window 7 Ultimate, IIS7.5 and PHP 5.3. ImageMagick-6.8.7-Q16 ghostscript 9.10
感谢和问候 穆罕默德·谢赫(Mohammed Shaikh)
Thanks and regards Mohammed Shaikh
推荐答案
尝试使用此
exec("<full path to binary> '-dNOPAUSE' '-sDEVICE=jpeg' '-r<resolution>'
'-g<dimensions>' '-dUseCIEColor' '-dTextAlphaBits=4' '-dGraphicsAlphaBits=4'
'-o<where you want the image stored>' '-dJPEGQ=<quality - I used 90>'
'<pdf file to resize>'", $outputArray);
如果占位符使用变量填充,则变量-如$resolution
-可以直接进入命令,例如-r$resolution
.
If the placeholders are filled in using variables, the variables - like $resolution
- just go straight in to the command, e.g. -r$resolution
.
这篇关于ghostscript在php中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!