Trying to clone an uncloneable object of class Imagic的解决方法
程序员文章站
2022-06-21 20:53:37
在windows下安装完后提示:fatal error: trying to clone an uncloneable object of class imagick in...
在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;
}
上一篇: 常按揉迎香穴能防感冒
推荐阅读
-
提示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技巧