Sha256: baf9330a00f2838c21ef5ed2290d4f69aa54d820b310d66ca5831edcd0c6d3da
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
require 'image_optimizer/version' require 'image_optimizer/shell' require 'image_optimizer/image_optimizer_base' require 'image_optimizer/jpeg_optimizer' require 'image_optimizer/png_optimizer' class ImageOptimizer include Shell attr_reader :path, :options def initialize(path, options = {}) @path = path @options = options end def optimize identify_format if options[:identify] JPEGOptimizer.new(path, options).optimize PNGOptimizer.new(path, options).optimize end private def identify_format if identify_bin? match = run_command("#{identify_bin} -ping#{quiet} #{path}").match(/PNG|JPG|TIFF|GIF|JPEG/) if match options[:identified_format] = match[0].downcase end else warn 'Attempting to retrieve image format without identify installed. Using file name extension instead...' end end def quiet ' -quiet' if image_magick? end def image_magick? !!which('mogrify') end def identify_bin? !!identify_bin end def identify_bin ENV['IDENTIFY_BIN'] || which('identify') end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
image_optimizer-1.5.0 | lib/image_optimizer.rb |
image_optimizer-1.4.0 | lib/image_optimizer.rb |
image_optimizer-1.3.0 | lib/image_optimizer.rb |