validationImageMagick安装

我的网站托pipe表示ImageMagic已经预先安装在服务器上。 我在phpinfo()的输出中快速search“ImageMagick”,但是我什么也没find。 我不能在服务器SSH,所以有没有办法在PHP我可以validation安装?

尝试这个:

<?php //This function prints a text array as an html list. function alist ($array) { $alist = "<ul>"; for ($i = 0; $i < sizeof($array); $i++) { $alist .= "<li>$array[$i]"; } $alist .= "</ul>"; return $alist; } //Try to get ImageMagick "convert" program version number. exec("convert -version", $out, $rcode); //Print the return code: 0 if OK, nonzero if error. echo "Version return code is $rcode <br>"; //Print the output of "convert -version" echo alist($out); ?> 
 if (!extension_loaded('imagick')) echo 'imagick not installed'; 

编辑:下面的信息和脚本只适用于iMagick类 – 这是不是默认与ImageMagick添加!

如果我想知道imagemagick是否已经安装并且实际上是作为一个php扩展工作的,我将这个代码片段粘贴到一个web可访问的文件中

 <?php error_reporting(E_ALL); ini_set( 'display_errors','1'); /* Create a new imagick object */ $im = new Imagick(); /* Create new image. This will be used as fill pattern */ $im->newPseudoImage(50, 50, "gradient:red-black"); /* Create imagickdraw object */ $draw = new ImagickDraw(); /* Start a new pattern called "gradient" */ $draw->pushPattern('gradient', 0, 0, 50, 50); /* Composite the gradient on the pattern */ $draw->composite(Imagick::COMPOSITE_OVER, 0, 0, 50, 50, $im); /* Close the pattern */ $draw->popPattern(); /* Use the pattern called "gradient" as the fill */ $draw->setFillPatternURL('#gradient'); /* Set font size to 52 */ $draw->setFontSize(52); /* Annotate some text */ $draw->annotation(20, 50, "Hello World!"); /* Create a new canvas object and a white image */ $canvas = new Imagick(); $canvas->newImage(350, 70, "white"); /* Draw the ImagickDraw on to the canvas */ $canvas->drawImage($draw); /* 1px black border around the image */ $canvas->borderImage('black', 1, 1); /* Set the format to PNG */ $canvas->setImageFormat('png'); /* Output the image */ header("Content-Type: image/png"); echo $canvas; ?> 

你应该看到一个你好世界graphics:

在这里输入图像描述

您可以轻松地检查PHP中的Imagick类。

 if( class_exists("Imagick") ) { //Imagick is installed } 

试试这个应该找出ImageMagick在哪里的一次性解决scheme,如果你有权访问它…

这发现我的Godaddy托pipe所有版本。

上传这个文件到你的服务器,并将其称为ImageMagick.php或其他东西,然后运行它。 你会得到所有你需要的信息…希望…

祝你好运。

 <? /* // This file will run a test on your server to determine the location and versions of ImageMagick. //It will look in the most commonly found locations. The last two are where most popular hosts (including "Godaddy") install ImageMagick. // // Upload this script to your server and run it for a breakdown of where ImageMagick is. // */ echo '<h2>Test for versions and locations of ImageMagick</h2>'; echo '<b>Path: </b> convert<br>'; function alist ($array) { //This function prints a text array as an html list. $alist = "<ul>"; for ($i = 0; $i < sizeof($array); $i++) { $alist .= "<li>$array[$i]"; } $alist .= "</ul>"; return $alist; } exec("convert -version", $out, $rcode); //Try to get ImageMagick "convert" program version number. echo "Version return code is $rcode <br>"; //Print the return code: 0 if OK, nonzero if error. echo alist($out); //Print the output of "convert -version" echo '<br>'; echo '<b>This should test for ImageMagick version 5.x</b><br>'; echo '<b>Path: </b> /usr/bin/convert<br>'; exec("/usr/bin/convert -version", $out, $rcode); //Try to get ImageMagick "convert" program version number. echo "Version return code is $rcode <br>"; //Print the return code: 0 if OK, nonzero if error. echo alist($out); //Print the output of "convert -version" echo '<br>'; echo '<b>This should test for ImageMagick version 6.x</b><br>'; echo '<b>Path: </b> /usr/local/bin/convert<br>'; exec("/usr/local/bin/convert -version", $out, $rcode); //Try to get ImageMagick "convert" program version number. echo "Version return code is $rcode <br>"; //Print the return code: 0 if OK, nonzero if error. echo alist($out); //Print the output of "convert -version"; ?> 

在bash中:

 $ convert -version 

要么

 $ /usr/local/bin/convert -version 

没有必要写任何PHP文件只是为了检查。

如果您的ISP /托pipe服务已经安装了ImageMagick并将其位置置于PATH环境variables中,则可以find安装的版本和使用位置:

 <?php echo "<pre>"; system("type -a convert"); echo "</pre>"; ?>