PalletePNG
PalletePNG is a pure-ruby library that make it possible to render the transparent of a pallete-based PNG in PDF by converting the color-mode of the image.
Installation
Add this line to your application's Gemfile:
gem 'pallete_png'
And then execute:
$ bundle
Or install it yourself as:
$ gem install pallete_png
Usage
require 'pallete_png'
image = File.binread('/path/to/pallete-based-w-transparency.png')
converted_image = PalletePNG.to_transparency(image)
Exception
require 'pallete_png'
not_a_png_image = File.binread('/path/to/not_a_png.jpg')
begin
converted_image = PalletePNG.to_transparency(not_a_png_image)
rescue PalletePNG::Image::NotPNG
puts 'The image is not a PNG.'
end
Use with Prawn
Supported versions
Ruby 2.2, 2.3
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/hidakatsuya/pallete_png.
License
© 2016 Katsuya HIDAKA. See MIT-LICENSE for further details.