[英]Executing Imagemagick's convert returning error code 1
[edit after answer of Bonzo] after the following code, I am getting this error : [在Bonzo的答案后编辑]在以下代码之后,我收到此错误:
Array
(
[0] => magick: unable to create temporary file 'aboutproject1.pdf': Permission denied @ error/pdf.c/ReadPDFImage/476.
)
How can I permit cration of temporary file ? 如何允许创建临时文件? My current user is Daemon (apache/localhost)
我当前的用户是Daemon(apache / localhost)
[before edit] I am trying to issue a shell command from my PHP to convert a PDF to TIFF. [编辑前]我正在尝试从PHP发出shell命令以将PDF转换为TIFF。 But I am getting error code 1. Following is my code :
但是我收到错误代码1。以下是我的代码:
<?php
if(isset($_FILES['file_up']["name"])){
//print_r($_FILES);
$file_name = $_FILES['file_up']["name"];
$tmp_name = $_FILES['file_up']["tmp_name"];
if(move_uploaded_file($tmp_name, "$file_name")){
$onlyname = pathinfo($_FILES['file_up']['name'], PATHINFO_FILENAME);
chmod("$file_name", 0777);
//Command that is returning error code 1
//Iam running it on aboutproject.pdf STATIC for novv.
exec("/usr/local/Cellar/imagemagick/7.0.7-1/bin/convert aboutproject1.pdf anyuf.tif", $output, $retval);
//returning empty array
echo "output : ->"; print_r($output) ;
//returning error code 1
echo "RETURN : ->".$retval;
if ($retval == 0){
echo "First command executed !";
}
}
exit();
}
?>
PLEASE, NOT FOLLOWING : 请注意以下事项:
man convert
through same PHP script, it gives me the proper output(within the same folder) man convert
,它会为我提供正确的输出(在同一文件夹中) Please help me I am stuck. 请帮助我,我被卡住了。
Version 7 uses magick rather than convert. 版本7使用magick而不是convert。 convert may still work but it depends on how Imagemagick was installed.
转换可能仍然有效,但这取决于Imagemagick的安装方式。
You could try this method of error reporting and see if you get any more information: 您可以尝试这种错误报告方法,看看是否获得更多信息:
$array=array();
echo "<pre>";
exec("/usr/local/Cellar/imagemagick/7.0.7-1/bin/convert aboutproject1.pdf anyuf.tif 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
Instead of using this /usr/local/Cellar/imagemagick/7.0.7-1/bin/convert I would just use magick. 与其使用/usr/local/Cellar/imagemagick/7.0.7-1/bin/convert,不如使用magick。 If your version changes or the imagemagick location changes you will need to modify all your scripts.
如果版本更改或imagemagick位置更改,则需要修改所有脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.