Module: Smusher
- Extended by:
- Smusher
- Included in:
- Smusher
- Defined in:
- lib/smusher.rb,
lib/smusher/puny_png.rb,
lib/smusher/smush_it.rb
Defined Under Namespace
Constant Summary collapse
- MINIMUM_IMAGE_SIZE =
byte
20
- VERSION =
File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
Instance Method Summary collapse
-
#optimize_image(files, options = {}) ⇒ Object
optimize the given image converts gif to png, if size is lower can be called with a file-path or an array of files-paths.
-
#optimize_images_in_folder(folder, options = {}) ⇒ Object
fetch all jpg/png images from given folder and optimize them.
Instance Method Details
#optimize_image(files, options = {}) ⇒ Object
optimize the given image converts gif to png, if size is lower can be called with a file-path or an array of files-paths
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/smusher.rb', line 20 def optimize_image(files,={}) service = [:service] || 'SmushIt' service = eval(service) Array(files).each do |file| () puts "THIS FILE IS EMPTY!!! #{file}" and return if size(file).zero? with_logging(file, [:quiet]) do write_optimized_data(file, service) end end end |
#optimize_images_in_folder(folder, options = {}) ⇒ Object
fetch all jpg/png images from given folder and optimize them
35 36 37 38 39 40 |
# File 'lib/smusher.rb', line 35 def optimize_images_in_folder(folder, ={}) () images_in_folder(folder, [:convert_gifs]).each do |file| optimize_image(file, ) end end |