This Gem allows converting CgBI (Apple's optimized PNG) images into standard PNG images. See http://iphonedevwiki.net/index.php/CgBI_file_format
Add this line to your application's Gemfile:
gem 'cgbi_to_png'
And then execute:
$ bundle
Or install it yourself as:
$ gem install cgbi_to_png
opng = CgBItoPNG::from_file('apple-optimized-image.png')
opng.unoptimize
opng.to_file('standard-image.png')
require 'cgbi_to_png'
require 'fileutils'
OUT_DIR = 'unoptimized_pngs'
FileUtils.mkdir_p OUT_DIR
succesfull = []
failed = {}
Dir.foreach('.') do |item|
next unless item[/.png$/]
begin
opng = CgBItoPNG::from_file(item)
opng.unoptimize if opng.optimized?
opng.to_file(File.join(OUT_DIR, item))
succesfull << item
rescue Exception => e
failed[item] = e
end
puts "Done"
puts "#{succesfull.count} successful"
puts "#{failed.count} failed"
failed.each do |k,v|
puts "#{k}: #{v}"
end
end
- Currently this Gem only supports 8bit color depth and Color Type '6' (RGB + alpha)
- Interlacing is not supported
- Alpha channel correction is not performed
Taking into account the expected usage of this Gem (viewing iOS optimized icons) these limitations are probably not a problem.
- Fork it ( http://github.com/jappelbe/cgbi_to_png/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request