Home Backend Development PHP Tutorial Trying to clone an uncloneable object of class Imagic的解决_PHP

Trying to clone an uncloneable object of class Imagic的解决_PHP

Jun 01, 2016 pm 12:13 PM
object

在windows下安装完后提示:
Fatal error: Trying to clone an uncloneable object of class Imagick in C:\www\hx\pdf_to_png.php on line 17

使用IIS和Apache均会有这个提示。经多次测试后,发现两种解决方法:

1.php.ini中; Enable compatibility mode with Zend Engine 1 (PHP 4.x)
zend.ze1_compatibility_mode = Off

默认是On,改为Off后,即可解决。

2.使用imagick::...这种方法调用。
即$im->setResolution(120, 120);可以改写为:
imagick::setResolution(120, 120);


如果其它扩展出现这类错误,一般也是可以使用这两种方法解决的。

附pdf转png的程序代码片断:
复制代码 代码如下:
        function pdf2png($pdf, $filename, $page=0) {         
            if (!extension_loaded('imagick')) {
                exit('no imagick');
                return false;               
            }
            if (!file_exists($pdf)) {
                return false;
            } 
            $im = new Imagick();
            $im->setResolution(120, 120);
            $im->setCompressionQuality(100);
            $im->readImage($pdf . "[" . $page . "]");
            $im->setImageFormat('png');
            $im->writeImage($filename);
            $im->readImage($filename);
            $im->resizeImage(120, 150, Imagick::FILTER_LANCZOS, 1);
            $im->writeImage($filename);
            return $filename;
        }

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the methods of converting java Object to byte and byte to Object? What are the methods of converting java Object to byte and byte to Object? Apr 20, 2023 am 11:37 AM

What are the methods of converting java Object to byte and byte to Object?

How to use methods in Java Object class How to use methods in Java Object class Apr 18, 2023 pm 06:13 PM

How to use methods in Java Object class

PHP Notice: Trying to get property of non-object solution PHP Notice: Trying to get property of non-object solution Jun 24, 2023 pm 09:34 PM

PHP Notice: Trying to get property of non-object solution

Solution to PHP Notice: Trying to get property of non-object Solution to PHP Notice: Trying to get property of non-object Jun 22, 2023 pm 02:43 PM

Solution to PHP Notice: Trying to get property of non-object

Java uses the getClass() function of the Object class to obtain the runtime class of the object Java uses the getClass() function of the Object class to obtain the runtime class of the object Jul 24, 2023 am 11:37 AM

Java uses the getClass() function of the Object class to obtain the runtime class of the object

How to use Java Object class How to use Java Object class May 13, 2023 pm 05:13 PM

How to use Java Object class

How to use Object class and System class in Java? How to use Object class and System class in Java? Apr 23, 2023 pm 11:28 PM

How to use Object class and System class in Java?

Java Object class method instance analysis Java Object class method instance analysis Apr 18, 2023 pm 05:49 PM

Java Object class method instance analysis

See all articles