简体   繁体   English

为什么会出现此错误

[英]Why am I getting this error

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 ? 文件名的路径是正确的,但是由于某些原因,运行脚本时出现以下错误。phpinfo显示我已安装imagick ...并且我下载了ghostscript,但不确定是否可以检测到它。我所做的就是将其下载到我的计算机中……我缺少什么吗? I'm confused on how to get ghostscript to work with php 我对如何使ghostscript与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 致命错误:C:\\ xampp \\ htdocs \\ tms \\ test_php.php中出现消息“无法处理空的Imagick对象”的未捕获异常'ImagickException':7堆栈跟踪:#0 C:\\ xampp \\ htdocs \\ tms \\ test_php.php (7):Imagick-> setimageresolution(1250,1250)#1 {main}抛出在第7行的C:\\ xampp \\ htdocs \\ tms \\ test_php.php中

PHP Code: PHP代码:

    //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();

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). 看起来Imagick类的构造函数应该只将一个参数传递给它,但是您要传递两个参数($ filename,0777)。

Replace 更换

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

with

$im = new Imagick($filename); 

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM