簡體   English   中英

在Linux專用服務器上執行Imagemagick php

[英]Imagemagick php execution on Linux Dedicated Server

我正在做一些ImageMagick的東西。 這是我的命令:

/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

此代碼會對圖像進行羽化和調整大小。 它在shell和php代碼中的localhost(我在localhost上使用xampp)上工作正常,並且在shell中的專用服務器上工作正常。

但是,它在使用php代碼的專用服務器上根本不起作用。 這是我的代碼:

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

ImageMagick正確安裝在服務器上並且活動,我在phpinfo中看到它()任何想法為什么會發生,我該怎么辦?

命令convert可能不在Web服務器使用的$PATH環境變量中。 使用完整路徑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);

要查找convert的位置,請從服務器上的shell執行

$ which convert

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM