Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从pdf转换图像在php中不起作用_Php_Image Processing_Imagemagick_Ghostscript - Fatal编程技术网

从pdf转换图像在php中不起作用

从pdf转换图像在php中不起作用,php,image-processing,imagemagick,ghostscript,Php,Image Processing,Imagemagick,Ghostscript,我在我的C驱动器中安装了ghostscript和imagemagick,在D驱动器中安装了wamp服务器,其中一个文件包含代码 <?php exec('convert "sd.pdf[0]" -colorspace RGB -geometry 200 "document.png"'); ?> 您需要删除或转义双引号,它在Windows上无法正常工作。 有关更多信息,请查看我的execute()方法: 与IM最大的贡献者之一聊天 如果没有任何引号,带有空格的rgb(255、255、

我在我的C驱动器中安装了ghostscript和imagemagick,在D驱动器中安装了wamp服务器,其中一个文件包含代码

<?php exec('convert "sd.pdf[0]" -colorspace RGB -geometry 200 "document.png"'); 
?>

您需要删除或转义双引号,它在Windows上无法正常工作。
有关更多信息,请查看我的execute()方法:

与IM最大的贡献者之一聊天

如果没有任何引号,带有空格的rgb(255、255、255)将导致 问题。类似地,十六进制值中的#如果不是,可能会导致问题 引用。如果在windows上或使用 变量否则,对IM来说,单引号或双引号都可以。但如果 您正在从PHPExec调用IM命令,然后正如您所知,您 需要小心(或逃离它们)


转换是否在shell的路径中?您的Web服务器用户ID在该目录中是否具有写入权限?ghostscript是否可由Web服务器ID执行/访问?问题仅限于双引号
public function execute($command)
{
    # remove newlines and convert single quotes to double to prevent errors
    $command = str_replace(array("\n", "'"), array('', '"'), $command);
    # replace multiple spaces with one
    $command = preg_replace('#(\s){2,}#is', ' ', $command);
    # escape shell metacharacters
    $command = escapeshellcmd($command);
    # execute convert program
    exec($command);
}