douyue8364 2013-08-26 15:54
浏览 92
已采纳

为什么我收到此错误

The path of the filename is correct, but for some reason I'm getting the error below when i run the script .. phpinfo shows me imagick is installed ...and I downloaded ghostscript but I'm not sure if it detects it .. all I did was downloading it to my computer .. is there anything that I'm missing ? I'm confused on how to get ghostscript to work with php

Fatal error: Uncaught exception 'ImagickException' with message 'Can not process empty Imagick object' in C:\xampp\htdocs\tms\test_php.php:7 Stack trace: #0 C:\xampp\htdocs\tms\test_php.php(7): Imagick->setimageresolution(1250, 1250) #1 {main} thrown in C:\xampp\htdocs\tms\test_php.php on line 7

PHP Code:

    //echo phpinfo();
    $filename = dirname(__FILE__).'\_media\4055-Beckman-Lead-App\client\fpo.pdf';
    echo $filename;
    $im = new imagick( $filename, 0777); 
    $im->setImageResolution(1250,1250);
    $im->setImageColorspace(255);
    $im->setCompression(Imagick::COMPRESSION_JPEG);
    $im->setCompressionQuality(100);
    $im->setImageFormat('jpeg');

    $im->writeImage('thumb.jpg');
    $im->clear();
    $im->destroy();
  • 写回答

1条回答 默认 最新

  • dt4320279 2013-08-26 16:01
    关注

    It appears as though the constructor for the Imagick class should only have one parameter passed to it, but you are passing two ($filename, 0777).

    Replace

    $im = new imagick( $filename, 0777); 
    

    with

    $im = new Imagick($filename); 
    

    http://www.php.net/manual/en/imagick.construct.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。