doudao1922 2016-01-18 07:06
浏览 38
已采纳

Imagick转换vs imagick PHP

So I built a site that creates thumbnails using a php script that uses imagick for thumbnail creation. On my personal web host (Hostmonster), this works fine. When I made a copy of my site and uploaded it to my client's site (hosted on domain.com) it failed. Asking Domain.com what was up, they said:

"We have ImageMagick binaries. But it is not complied to PHP so IMAGICK won’t work. So, you will not be able to use IMAGICK as PHP built-in class. You have to use the alternative ‘convert’ utility"

I've never used the "convert utility" before, so I'm not sure what they're talking about. Should I look into this more? Or fire them and just stick with my original host (Hostmonster) where imagick works in PHP? I feel like I should know about this alternative to be more well-rounded in my knowledge, but wondering if its worth my time to learn it, or just forget it and move on.

Suggestions about how to go forward, or resources on this alternative would be appreciated. Thanks.

  • 写回答

3条回答 默认 最新

  • doutaoer3148 2016-01-18 09:26
    关注

    What they are talking about is using PHP's exec() function to execute ImageMagick the same way as you would do it from the command line. There are hundreds of examples on SO of using ImageMagick from the command line, just search for ImageMagick and convert which is the name of the main binary you would use at the command line.

    The syntax is pretty simple:

    convert input.png ...<processing> ... output.png
    

    So, you might do

    convert input.jpg -thumbnail x320 -quality 80 result.png
    

    If you want to do that in PHP, your ISP is suggesting you use:

    $cmd = "/usr/local/bin/convert '/path/to/input.jpg' -thumbnail x320 -quality 80 '/path/to/result.png'";
    exec($cmd, $output, $retval);
    

    I can't really comment on the relative efficiency, merits or otherwise (though it smacks of laziness or incompetence on their part), but it should work fine.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题