{"action":"created","issue":{"url":"https://api.github.com/repos/prawnpdf/prawn/issues/783","labels_url":"https://api.github.com/repos/prawnpdf/prawn/issues/783/labels{/name}","comments_url":"https://api.github.com/repos/prawnpdf/prawn/issues/783/comments","events_url":"https://api.github.com/repos/prawnpdf/prawn/issues/783/events","html_url":"https://github.com/prawnpdf/prawn/issues/783","id":45346854,"number":783,"title":"Palleted PNG w. transparency unsupported","user":{"login":"mfly","id":449001,"avatar_url":"https://avatars.githubusercontent.com/u/449001?v=3","gravatar_id":"","url":"https://api.github.com/users/mfly","html_url":"https://github.com/mfly","followers_url":"https://api.github.com/users/mfly/followers","following_url":"https://api.github.com/users/mfly/following{/other_user}","gists_url":"https://api.github.com/users/mfly/gists{/gist_id}","starred_url":"https://api.github.com/users/mfly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfly/subscriptions","organizations_url":"https://api.github.com/users/mfly/orgs","repos_url":"https://api.github.com/users/mfly/repos","events_url":"https://api.github.com/users/mfly/events{/privacy}","received_events_url":"https://api.github.com/users/mfly/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/prawnpdf/prawn/labels/change-request","name":"change-request","color":"eb6420"},{"url":"https://api.github.com/repos/prawnpdf/prawn/labels/confirmed-bug","name":"confirmed-bug","color":"e11d21"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2014-10-09T09:49:09Z","updated_at":"2015-12-19T18:34:07Z","closed_at":"2015-11-21T18:47:51Z","body":"I was creating some PDF files with PNG images and some of them came out with transparency issues. After some tests I narrowed the issue to palleted PNG files. Unfortunately, most of images I use are palleted so it was a real problem.\r\n\r\nQuick look at the code reveals that transparency is completely broken for palleted files:\r\nhttps://github.com/prawnpdf/prawn/blob/master/lib/prawn/images/png.rb#L211\r\n\r\nThen I created a test script and a set of test images (https://dl.dropboxusercontent.com/u/20390548/prawn-png.tar.bz2). As expected, everything seems to work, except the palleted PNG with transparency.\r\n\r\nMaybe it would be a better idea to use some external library than to try implement PNG handling inside prawn?\r\n\r\nSuggested workaround for issues with transparency in PNG files is to use an external tool to convert files into rgba/grayscale mode before using them with prawn.\r\n\r\nFor me, the best solution is flattening the files with white background and converting it to 8-bit-per-channel RGB with the following command:\r\n```\r\nconvert #{file} -background white -flatten -define png:color-type=2 -define png:bit-depth=8 #{out_file}\r\n```"},"comment":{"url":"https://api.github.com/repos/prawnpdf/prawn/issues/comments/166012957","html_url":"https://github.com/prawnpdf/prawn/issues/783#issuecomment-166012957","issue_url":"https://api.github.com/repos/prawnpdf/prawn/issues/783","id":166012957,"user":{"login":"cheba","id":7405,"avatar_url":"https://avatars.githubusercontent.com/u/7405?v=3","gravatar_id":"","url":"https://api.github.com/users/cheba","html_url":"https://github.com/cheba","followers_url":"https://api.github.com/users/cheba/followers","following_url":"https://api.github.com/users/cheba/following{/other_user}","gists_url":"https://api.github.com/users/cheba/gists{/gist_id}","starred_url":"https://api.github.com/users/cheba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cheba/subscriptions","organizations_url":"https://api.github.com/users/cheba/orgs","repos_url":"https://api.github.com/users/cheba/repos","events_url":"https://api.github.com/users/cheba/events{/privacy}","received_events_url":"https://api.github.com/users/cheba/received_events","type":"User","site_admin":false},"created_at":"2015-12-19T18:34:07Z","updated_at":"2015-12-19T18:34:07Z","body":"@sublimecoder Quick code inspection seem to show that only color would be kept and transparency data would simply be ignored. \r\n\r\nIn pseudo code it would look like the following transformation:\r\n```ruby\r\ndef pixel_color(r, g, b, a)\r\n  [r, g, b, 1.0]\r\nend\r\n```"}}