当前位置:  开发笔记 > 编程语言 > 正文

验证ImageMagick安装

如何解决《验证ImageMagick安装》经验,为你挑选了6个好方法。

我的网站托管说ImageMagic已预先安装在服务器上.我在phpinfo()的输出中快速搜索了"ImageMagick",但我什么都没发现.我不能在服务器上SSH,所以有没有办法在PHP我可以验证安装?



1> bcosca..:

这是短暂而甜蜜的:

if (!extension_loaded('imagick'))
    echo 'imagick not installed';



2> wajiw..:

试试这个:

";
  for ($i = 0; $i < sizeof($array); $i++) {
    $alist .= "
  • $array[$i]"; } $alist .= ""; 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
    "; //Print the output of "convert -version" echo alist($out); ?>

  • 如果安装了ImageMagick应用程序,则测试,而不是PHP模块
    这是一个解决问题的人的解决方案.向下投票不是正确的答案.如果您对礼仪有疑问,请在meta.stackoverflow.com中询问

    3> Nate Flink..:

    编辑:下面的信息和脚本仅适用于iMagick类 - 默认情况下不会添加ImageMagick!

    如果我想知道imagemagick是否已安装并且实际上是作为php扩展工作,我将此片段粘贴到Web可访问文件中

    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;
    ?>
    

    你应该看到一个hello world图形:

    在此输入图像描述



    4> Spencer Haki..:

    您可以在PHP中轻松检查Imagick类.

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


    **important:**有时这会返回FALSE但是`extension_loaded('imagick')`返回TRUE!所以我想更好的是:`if(extension_loaded('imagick')|| class_exists("Imagick")){/*做想象*/}`

    5> Ashraf Slama..:

    在bash中:

    $ convert -version
    

    要么

    $ /usr/local/bin/convert -version
    

    无需编写任何PHP文件即可查看.


    只是为了省去别人的麻烦-转换是imagick安装的shell命令,因此上述内容直接与其进行了交谈,以检查它是否在其中+1

    6> 小智..:

    试试这个一次性解决方案应该找出ImageMagick的位置,如果你有权访问它...

    这发现我的Godaddy托管上的所有版本.

    将此文件上传到您的服务器并调用它ImageMagick.php或其他东西然后运行它.您将获得所需的所有信息......希望......

    祝好运.

    Test for versions and locations of ImageMagick';
    echo 'Path:  convert
    '; function alist ($array) { //This function prints a text array as an html list. $alist = "
      "; for ($i = 0; $i < sizeof($array); $i++) { $alist .= "
    • $array[$i]"; } $alist .= "
    "; return $alist; } exec("convert -version", $out, $rcode); //Try to get ImageMagick "convert" program version number. echo "Version return code is $rcode
    "; //Print the return code: 0 if OK, nonzero if error. echo alist($out); //Print the output of "convert -version" echo '
    '; echo 'This should test for ImageMagick version 5.x
    '; echo 'Path: /usr/bin/convert
    '; exec("/usr/bin/convert -version", $out, $rcode); //Try to get ImageMagick "convert" program version number. echo "Version return code is $rcode
    "; //Print the return code: 0 if OK, nonzero if error. echo alist($out); //Print the output of "convert -version" echo '
    '; echo 'This should test for ImageMagick version 6.x
    '; echo 'Path: /usr/local/bin/convert
    '; exec("/usr/local/bin/convert -version", $out, $rcode); //Try to get ImageMagick "convert" program version number. echo "Version return code is $rcode
    "; //Print the return code: 0 if OK, nonzero if error. echo alist($out); //Print the output of "convert -version"; ?>

    推荐阅读
    wurtjq
    这个屌丝很懒,什么也没留下!
    DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
    Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有