amitdivya / dompdf

Automatically exported from code.google.com/p/dompdf
0 stars 0 forks source link

Trying to clone an uncloneable object of class Imagick #453

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Add transparent PNG to pdf in <img> tag.

What is the expected output? What do you see instead?
Fatal error: Trying to clone an uncloneable object of class Imagick in 
/home/noc/lib/dompdf/lib/class.pdf.php on line 4329

What version of dompdf are you using? What version of PHP? On what
operating system?
Ubuntu, php 5.3.2 ,imagemagick 6.5.7.8 Q16 , dompdf 0.6.0b3

Please provide the HTML source code you want to convert, or any additional
information.

I've fixed it for my situation by creating an additional object instead of a 
clone:

- // Get opacity channel (negative of alpha channel)
-      $alpha_channel = clone $imagick;

+ // Get opacity channel (negative of alpha channel)
+     $alpha_channel = new Imagick($file);
+     $alpha_channel->setFormat('png');

Original issue reported on code.google.com by MariusKa...@gmail.com on 26 Mar 2012 at 9:27

GoogleCodeExporter commented 9 years ago
This seems to be related to zend.ze1_compatibility_mode in php.ini :
https://bugs.php.net/bug.php?id=30102&edit=1

But we can adapt our code to work everytime, like you did.

Original comment by fabien.menager on 26 Mar 2012 at 10:25

GoogleCodeExporter commented 9 years ago
Hello Fabien,

Yes I found that reference too, but in my case this wasn't it. My config by 
default does not specify zend.ze1_compatibility_mode anywhere and when I 
explicitly set it to 'off' the error did not go away. Anyway my proposed quick 
fix seems to work so far and I do not think it breaks anything else. O... and I 
think we now have the most beautiful invoice PDFs in the world, thanks to your 
great lib ;) 

Regards,
Marius Karthaus

Original comment by MariusKa...@gmail.com on 26 Mar 2012 at 9:07

GoogleCodeExporter commented 9 years ago
if use "zend.ze1_compatibility_mode = off" and get this error too!

Original comment by mrsmithl...@gmail.com on 23 Apr 2012 at 9:52

GoogleCodeExporter commented 9 years ago
Issue 506 has been merged into this issue.

Original comment by eclecticgeek on 13 Jun 2012 at 7:04

GoogleCodeExporter commented 9 years ago
The compatibility setting was deprecated and removed in PHP 5.3, which could be 
why it has no affect on some installations.

Imagick used to have a built-in clone() method, but it has been deprecated in 
favor of the clone keyword in v3.1.
http://us3.php.net/manual/en/imagick.clone.php
http://pecl.php.net/package-info.php?package=imagick&version=3.1.0b1

What version of the PECL extension are you using? Perhaps the error only 
appears in versions of the extension prior to 3.1 (i.e. they aren't compatible 
with the clone keyword)? Unless we find a solution it may be worthwhile to just 
create a new object instead of using a clone. This is already how the code is 
written for Gmagick.

Original comment by eclecticgeek on 13 Jun 2012 at 7:44

GoogleCodeExporter commented 9 years ago

Original comment by eclecticgeek on 24 May 2013 at 3:00