Module: Chico
- Defined in:
- lib/chico/bitmapper.rb,
lib/chico.rb,
lib/chico/fetcher.rb,
lib/chico/extractor.rb
Overview
Unpack an ico bitmap
Defined Under Namespace
Classes: Bitmapper, Extractor, Fetcher
Class Method Summary collapse
- .extract_from_file(filepath, dest_dir, options = {}) ⇒ Object
- .extract_from_url(url, dest_dir, options = {}) ⇒ Object
Class Method Details
.extract_from_file(filepath, dest_dir, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/chico.rb', line 8 def self.extract_from_file(filepath, dest_dir, ={}) ex = Extractor.new(IO.read(filepath)) basename = File.basename(filepath, File.extname(filepath)) ex.entries.each do |entry| ext = "#{entry[:width]}x#{entry[:height]}" content = ex.image_for(entry) File.open(File.join(dest_dir, "#{basename}.#{ext}.png"), 'wb') do |f| f.write content end end end |