通过PHP

时间:2017-09-17 10:35:49

标签: php command-line imagemagick tesseract

我正在尝试使用某种算法的代码,在这种代码中它会命令命令行工具来提供某些输出。

这是我的代码:

<?php 
if(isset($_FILES['file_up']["name"])){

if(move_uploaded_file($tmp_name, "$file_name")){

   $onlyname = pathinfo($_FILES['file_up']['name'], PATHINFO_FILENAME);

//execute command to convert pdf to tif through LOCALLY INSTALLED image rick
    $last_line = system("/usr/local/Cellar/imagemagick/7.0.7-1/bin/convert -density 300 -trim $onlyname.pdf  -quality 100 ocr_binary.tif", $retval);

    if ($retval == 0){

    echo "First command executed !";    
    $last_line = system("/usr/local/Cellar/tesseract/3.05.01/bin/tesseract ocr_binary.tiff $onlyname -l mar", $retval);
    if ($retval == 0){
    echo "success";
        }
     }
else{
        echo "ERROR in command one";
    } }
    else {
      echo "<P>MOVE UPLOADED FILE FAILED!</P>";
   }
exit();
}
?>

在这段代码中,我通过PHP(给定777权限)脚本和文件夹来命令ImageMagick和tesseract。

问题:

  • ImageMagick未转换为TIF
  • 返回错误代码为1(我对文件夹和脚本授予了777权限)

请帮忙

0 个答案:

没有答案