dongyao4419 2012-04-17 09:25
浏览 82
已采纳

在Linux专用服务器上执行Imagemagick php

I'm doing some ImageMagick stuff. Here is my command:

/usr/bin/convert /home/setsail/public_html/microsite/images
/tmp/fe0e3b88601d254befc115ca6a50365b.png -alpha set -channel alpha -background none 
-vignette 0x3 -resize 66x89 /home/setsail/public_html/microsite/images/oval_thumb
/77bda03b6358b89efbe747ae414bd75f.png

This code feathers and resizes the image. It works fine on localhost (I'm using xampp on localhost) both in the shell and in php code, and works fine on my dedicated server in the shell.

But, it doesn't work at all on dedicated server with php code. Here is my code:

$cmd = "convert ".realpath($temp1)." -alpha set -channel alpha -background none    -vignette 0x3 resize ".$width."x".$height." ".$dest_img;
exec($cmd);

ImageMagick is properly installed on server and active as well as I see it in phpinfo() Any ideas why it's happening and what should i do?

  • 写回答

1条回答 默认 最新

  • doubaoguo7469 2012-04-17 09:27
    关注

    The command convert may not be in the $PATH environment variable being used by the web server. Use the full path to convert:

    // Substitute the full path for /usr/bin
    $cmd = "/usr/bin/convert ".realpath($temp1)." -alpha set -channel alpha -background none    -vignette 0x3 resize ".$width."x".$height." ".$dest_img;
    
    $results = array();
    $return_code = NULL;
    exec($cmd, $results, $return_code);
    
    // Check the output of the command for error:
    var_dump($results);
    var_dump($return_code);
    

    To find convert's location, from a shell on your server do

    $ which convert
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部