rvpatel / dompdf

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

PNG images showing up as white if utilizing ImageMagick #426

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Include a PNG image w/ a full alpha channel in the page's content (PNG 
images with binary transparency seem to be fine).
2. Have a server with ImageMagick 2.2.1 (at least this is what my server has 
[Rackspace Cloud]).
3. Generate PDF.

What is the expected output? What do you see instead?
The image should look like it does on the webpage. Instead, it shows the image 
as being completely white while retaining the alpha channel (ex. a circular 
image with a logo & transparent background just ends up showing as a white 
circle).

What version of dompdf are you using? What version of PHP? On what
operating system?
dompdf 0.6 beta 3

Please provide the HTML source code you want to convert, or any additional
information.
Some investigation showed that the problem was the utilization of imagick. I 
found a fix that involves disabling imagick's PNG rendering & using the 
fallback image rendering instead (including it as an option in the config file 
so people can still use imagick if it works for them).

- Add the following line to "dompdf_config.custom.inc.php":
define("DOMPDF_ENABLE_IMAGICK", false);

- Change line 4324 of "class.pdf.php" from:
elseif (extension_loaded("imagick")) {
- to:
elseif (extension_loaded("imagick") && DOMPDF_ENABLE_IMAGICK) {

This makes it so the configuration file is disabling the buggy PNG processing. 
I looked into the color channels & imagick implementation to see if there was 
an issue there, but I didn't find anything wrong with it in my brief time 
looking through it. Also, you could set up a similar config option for gmagick .

Original issue reported on code.google.com by kzeni1 on 15 Feb 2012 at 3:46

GoogleCodeExporter commented 9 years ago
Hello, thank you for your bug report. When I wrote this part of the code, I had 
in mind to be compatible with imagick 3, but I see you use an older version. 
I'll have to take version 2 into account, but a lot has changed! 
http://pecl.php.net/package-changelog.php?package=imagick

Maybe you can also update your extension, using the command "pecl upgrade 
imagick"

Original comment by fabien.menager on 16 Feb 2012 at 8:45

GoogleCodeExporter commented 9 years ago
Ah, well the site I'm working with is on Rackspace Cloud Sites (managed 
hosting) so, unfortunately, I don't have access to update the version of 
imagick & nor can they update imagick for just one site.

Maybe have the condition check what version of imagick they're running in 
addition to seeing whether or not it's loaded (removes the need for the manual 
config setting from my suggested workaround).

Original comment by kzeni1 on 16 Feb 2012 at 6:09

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Sorry to resurrect an old discussion, but today I ran into the issue described 
above. I was running my PHP project which utilizes your DOMPDF on a Windows 
Server 2008 machine; worked perfectly. Recently migrated the project to a Cent 
OS machine, and now my PNG images print black and white - most of the time. 
Yes, it's intermittent when it appears to be rendered correctly, but thats 
about 10% of the time. Mind you, that I do have the latest version of 
ImageMagick installed.

I've temporarily saved the image as a JPEG to eliminate the issue at hand, but 
it's preferred to use transparent PNG images.

ImageMagick Version: 6.8.5-7
OS Version: CentOS 6.4 (2.6.32-358.6.2.el6.x86_64)
PHP Version: 5.5.0 RC1

Original comment by ccarve...@gmail.com on 23 May 2013 at 4:31

GoogleCodeExporter commented 9 years ago
@ccarver we've moved issue tracking over to github. You can catch up on this 
issue there: https://github.com/dompdf/dompdf/issues

Original comment by eclecticgeek on 24 May 2013 at 2:56

GoogleCodeExporter commented 9 years ago

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