dongyao4419 2012-04-17 17: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 17: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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试