提示Trying to clone an uncloneable object of class Imagic的解决
2011-10-27 00:00
711 查看
使用网上流传的一个程序实现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的程序代码片断:
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的解决方法
- vs2015 新建项目时提示Object reference not set to an instance of an object该怎么解决呢
- VS2010 出现错误提示“Error Creating Control - Object reference not set to an instance of an objec” 的解决方法
- Notice: Trying to get property of non-object problem(PHP)解决办法
- Unable to cast COM object of type 'System.__ComObject' to class type 的解决办法
- Visual Studio 2015打开ASP.NET MVC的View提示"Object reference not set to an instance of an object"错误的解决方案
- 我遇到的Object reference not set to an instance of an object.错误的解决办法
- Notice: Trying to get property of non-object problem(PHP)解决办法
- 解决此类问题:warning: unable to bind to property '' on class 'Object' (class is not an IEventDispatcher) .
- vs数据库访问出现Object reference not set to an instance of an object. 错误解决办法
- SQLServer2005打开表时出现“Object reference not set to an instance of an object. (SQLEditors)”错误的解决办法
- 解决调用context.Session["NAME"]时总出现Object reference not set to an instance of an object.异常的方法
- Notice: Trying to get property of non-object problem(PHP)解决办法 中间件只能跳转不能返任何数据
- VS2005 solution文件打开时弹出“object reference not set to an instance of an object”错误的解决方法
- 【已解决】Android的ADT调试期间出现提示:The Jar of this class file belongs to container ‘Android Dependencies’ whic
- <<DEITEL - Python How to Program 2002>>Special attributes of an object of a class.0.0.0.3
- silverlight beta2.0安装成功后新建silverlight项目出现object reference not set to an instance of an object的解决办法
- Server was unable to process request. ---> Object reference not set to an instance of an object解决