When you are finished installing Windows, you are prompted:
Fatal error:trying to clone a Uncloneable object of class Imagick in C:\www\hx\pdf_to_png.php on line 17
This hint is available with both IIS and Apache. After several tests, two solutions were found:
In 1.php.ini; Enable compatibility mode with Zend Engine 1 (PHP 4.x)
Zend.ze1_compatibility_mode = Off
The default is on, after off, you can resolve it.
2. Use Imagick::. This method invocation.
i.e. $im->setresolution (120, 120); can be rewritten as:
Imagick::setresolution (120, 120);
If this type of error occurs with other extensions, it is generally possible to use both methods to resolve them.
PDF to PNG program code fragment:
Copy 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;
}