Cloneable tip trying to clone a Uncloneable object of class Imagic resolution

Source: Internet
Author: User
Using a program on the Internet to implement PDF as PNG, you need to use the imagic extension. Prompt after installation under Windows:
Fatal error:trying to clone a Uncloneable object of class Imagick in C:\www\hx\pdf_to_png.php on line 17
This prompt is available with both IIS and Apache. After several tests, two solutions have been found:
In 1.php.ini; Enable compatibility mode with Zend Engine 1 (PHP 4.x)
Zend.ze1_compatibility_mode = Off
The default is on, which can be resolved after the switch is off.
2. Use Imagick:: ... This method is called.
i.e. $im->setresolution (120, 120); can be rewritten as:
Imagick::setresolution (120, 120);
If such errors are present in other extensions, they can generally be resolved using both methods.
Snippet of program code with PDF to PNG:

Copy the Code code as follows:


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 (Imagick::filter_lanczos, 1);
$im->writeimage ($filename);
return $filename;
}

The above describes the cloneable hint trying to the clone an Uncloneable object of class imagic resolution, including the cloneable aspect of the content, I hope to be interested in PHP tutorial friends helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.