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 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入