Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF Error: -22 - PNG has unsupported color type: 6 #149

Closed
LinArcX opened this issue Apr 27, 2024 · 1 comment
Closed

PDF Error: -22 - PNG has unsupported color type: 6 #149

LinArcX opened this issue Apr 27, 2024 · 1 comment

Comments

@LinArcX
Copy link

LinArcX commented Apr 27, 2024

try to download this png file(black and white):
https://icons8.com/icons/set/person

or even google fonts:
https://fonts.google.com/icons?icon.size=24&icon.color=%235f6368&icon.query=person

And load it:
pdf_add_image_file(pdf, NULL, x-10, y-30, 10, 10, "data/person.png");

Compilation is fine. but when I run it, I receive this error:
PDF Error: -22 - PNG has unsupported color type: 6

@AndreRenaud
Copy link
Owner

Unfortunately PDFGen doesn't support alpha channels in images. The simplest option is to flatten the image down to having a white background. If you have imagemagick installed, you can do this with:

convert person.png  -background white -flatten flatten.png

Then you can put flatten.png into your PDF without issue.

@LinArcX LinArcX closed this as completed Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants