packetmonkey / prawn-gmagick

Use GraphcisMagick to load images into a Prawn document
https://github.com/packetmonkey/prawn-gmagick/
13 stars 6 forks source link

Some PNGs don't show up at all #8

Closed tomprats closed 9 years ago

tomprats commented 9 years ago

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

packetmonkey commented 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.

tomprats commented 9 years ago

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:

linear_naturalist_300_360

packetmonkey commented 9 years ago

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.

tomprats commented 9 years ago

Kinda makes sense but is definitely over my head a bit. Is there anything I could be doing to help?

tomprats commented 9 years ago

I found another image that shows up really funky. I've attached the image and an example of how it shows up.

tp

screen shot 2015-05-04 at 6 07 17 pm

packetmonkey commented 9 years ago

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.

tomprats commented 9 years ago

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!

packetmonkey commented 9 years ago

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?

tomprats commented 9 years ago

Yep! All the ones I've found so far

packetmonkey commented 9 years ago

@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!

amajor commented 9 years ago

I ran through a few pngs that I was having the same trouble with, and this solution worked for me. Thanks!

tomprats commented 9 years ago

Works perfectly! Thanks @packetmonkey

packetmonkey commented 9 years ago

v0.0.8 is live on rubygems.org