Closed tomprats closed 9 years ago
Bummer you are having some problems, can you please make available some of the PNG files you are having problems with and a code snippet that reproduces the problem so I can see it in action? Hopefully we can sort out what is going on.
Sorry for my delayed response. I had deleted all the files that weren't working and then had to find new another that would cause it. This should be one of them:
I am able to reproduce the problem, my current theory is that the BitsPerComponent of your image is 5 bits where the other PNG files I have used are 8. It's possible I made an assumption about 8 bit depth somewhere in my code and that's why this image is not working where graphics magick is able to identify the file correctly.
We need to see if I am in fact making that incorrect assumption in the extension or possibly use a lower level graphics magick function to access the pixel information differently so graphcis magick takes that into account for us.
Kinda makes sense but is definitely over my head a bit. Is there anything I could be doing to help?
I found another image that shows up really funky. I've attached the image and an example of how it shows up.
Well that's interesting. You just run into all the fun PNG files it seems. And I tested and your second png does work in Prawn natively so I am presumably doing something wrong in prawn-gmagick.
I'll try to spend some time digging into this when I can and see what is going on. Thanks for the example images, it's a big help in trying to run this down.
I've run into a couple more images that cause create the same "image" as the latest one. Let me know if it's helpful to have these too!
Do all of the other images contain only a single color and transparency? Like only green on a transparent background or black on a transparent background for example?
Yep! All the ones I've found so far
@tomprats Good news! I think I figured out what is going on here.
Can you please try the fix-image-depth branch and confirm that it works for you? In my tests using both from your example images and examples from my application that was also seeing the problem, everything appears to be working.
Once you confirm it works for you I'll cut a new release of the gem.
Thanks!
I ran through a few pngs that I was having the same trouble with, and this solution worked for me. Thanks!
Works perfectly! Thanks @packetmonkey
v0.0.8 is live on rubygems.org
I'm using a python library to convert Font Awesome icons to pngs and it seems like none of them show up in the Prawn document, despite not raising an error.
I've also run into this issue with a couple other PNG's. Using the library I could open up the image, but I don't understand the internals enough to figure out why it wouldn't show up.
This project helped me fix transparency issues with other PNGs so I'm very thankful for it's existence. My current solution might involve just converting the Font Awesome images to JPGs, but that won't work for images I get from APIs.
Thanks! Tom