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.