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

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

报告相同问题?

悬赏问题

  • ¥15 使用yolov5-7.0目标检测报错
  • ¥15 对于这个问题的解释说明
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备