手机
当前位置:查字典教程网 >编程开发 >php教程 >Trying to clone an uncloneable object of class Imagic的解决方法
Trying to clone an uncloneable object of class Imagic的解决方法
摘要:在windows下安装完后提示:Fatalerror:TryingtocloneanuncloneableobjectofclassImag...

在windows下安装完后提示:

Fatal error: Trying to clone an uncloneable object of class Imagick in C:wwwhxpdf_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的解决方法】相关文章:

php分别做为cgi和module来运行的配置

PHP安全编程之加密功能

提升PHP速度全攻略

第十四节 命名空间 [14]

PHP5 安装方法

php动态函数调用方法

php实现随机显示图片方法汇总

WordPress博客程序常见错误的解决方法

PHP file_get_contents函数读取远程数据超时的解决方法

PHP脚本的10个技巧(3)

精品推荐
分类导航