doq13207 2017-06-06 01:04
浏览 46
已采纳

Imagemagick得到PHP的详细错误

I'm running the following Imagemagick command on many images. Some images fail, but I'm not sure why... how can I get a detailed error message or error number from ImageMagick with PHP to help with troubleshooting the failures?

$myexec = 'convert -trim -density 200 /path/filename.tif -resize 70% /path/filename.png';
exec($myexec, $output, $return);

if (!$return) {
//success
}else{
//failed
}
  • 写回答

1条回答 默认 最新

  • dongzan9069 2017-06-06 01:53
    关注

    In ImageMagick, you should read the input first (assuming it is a raster image and not a vector image), then settings, then operators that use those setting, then other settings. Also you should specify -units. PNG only supports density and units of pixelspercentimeter. But if you specify units of pixelsperinch, ImageMagick will automatically convert the density to a value in pixelspercentimeter that corresponds to the corresponding pixelsperinch. To see any textual error messages, try the following:

    $myexec = "convert /path/filename.tif -trim -resize 70% -units pixelsperinch -density 200 /path/filename.png 2>&1";
    exec($myexec, $output, $return);
    foreach($output as $text) {echo "$text<br>";}
    

    You might also want to specify a -fuzz XX% before -trim if the background is not perfectly uniform. XX is a value between 0.0 and 100.0

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?