提示Trying to clone an uncloneable object of class Imagic的
程序员文章站
2022-05-17 13:06:10
...
使用网上流传的一个程序实现pdf截图为png,需要使用Imagic扩展,安装后出现Trying to clone an uncloneable object of class Imagic提示,下面是具体的解决方法分享。
使用网上流传的一个程序实现pdf截图为png,需要使用Imagic扩展。在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;
}
上一篇: php 生成WML页面方法详解
下一篇: 高手,网站后台进不去了,
推荐阅读
-
提示Trying to clone an uncloneable object of class Imagic的解决
-
Trying to clone an uncloneable object of class Imagic的解决方法
-
cloneable 提示Trying to clone an uncloneable object of class Imagic的解决
-
Trying to clone an uncloneable object of class Imagic的解决方法
-
Trying to clone an uncloneable object of class Imagic的解决_PHP
-
Trying to clone an uncloneable object of class Imagic的解决
-
Trying to clone an uncloneable object of class Imagic的解决
-
new Memcached()的时候报Trying to clone an uncloneable object of class Memcached
-
提示Trying to clone an uncloneable object of class Imagic的
-
提示Trying to clone an uncloneable object of class Imagic的解决_php技巧