Reputation: 89
I am developing a pdf using TCPDF . But when I try to print a PNG image the background of the image in pdf looks dark ..
Please help me .. If any one know about its solution
Regards
Upvotes: 3
Views: 4009
Reputation: 4340
For anyone else looking for an answer to this - Example 42 on the TCPDF pages is your answer: https://tcpdf.org/examples/example_042/
It illustrates text under alpha image like this:
Upvotes: -1
Reputation: 943
This was happening to me for PNG images that were in the HTML that I was adding to the PDF (TCPDF) using writeHTMLCell.
I created the images with Gimp on Ubuntu and some of the images showed up with a black background. I eventually solved this by opening the PNG file, re-filling the transparent areas with pure white, then re-select that white area with the fuzzy select tool and delete it. So that the Channels tab looks like this:
With the Red, Green & Blue channels having white backgrounds and the alpha channel a black background. If that is inverted, then the PNG doesn't render correctly.
I then exported to PNG using these settings:
(Although for some greyscale images they looked washed out unless I changed the drop down to "automatic pixelformat".)
I'm sure someone with more graphics knowledge than me could understand more about what's going on here... but this was what I found after a lot of trial and error.
Upvotes: 0
Reputation: 6338
TCPDF uses GD or ImageMagick (via Imagick) for image manipulation. There is also built-in image manipulation. So it's a complex topic.
I had a transparency issue using TCPDF with ImageMagick on Debian 9. As you described the transparent background was replaced by black color in pdf generated. I could fix the issue by installing imagemagick-common
package additionally to imagemagick-6.q16
and php-imagick
.
Upvotes: -1
Reputation: 418
It depends on the transparency of the PNG. Possibly you are using alpha transparency in your png so please convert it to index transparency.
Upvotes: -1