lib/t_bird/processor.rb in t_bird-0.0.1 vs lib/t_bird/processor.rb in t_bird-0.0.2

- old
+ new

@@ -2,37 +2,44 @@ require 'mini_magick' module TBird class Processor - attr_reader :image, :thumbnail_size + attr_reader :image def initialize(file_blob) @image = MiniMagick::Image.read(file_blob) - @thumbnail_size = Configuration.thumbnail_size end def process(&block) - image.combine_options do |magick| - block.call(magick) if block_given? + image.combine_options do |img| + block.call(img) if block_given? end image end + def stream + image.write StringIO.new + end + + def original + image # noop + end + def resize(size) - process do |magick| - magick.resize size + process do |img| + img.resize size end end - def thumbnail - process do |magick| - magick.auto_orient - magick.thumbnail "x#{thumbnail_size*2}" - magick.resize "#{thumbnail_size*2}x<" - magick.resize "50%" - magick.gravity "center" - magick.crop "#{thumbnail_size}x#{thumbnail_size}+0+0" - magick.quality 92 + def thumbnail(thumbnail_size = Configuration.thumbnail_size) + process do |img| + img.auto_orient + img.thumbnail "x#{thumbnail_size*2}" + img.resize "#{thumbnail_size*2}x<" + img.resize "50%" + img.gravity "center" + img.crop "#{thumbnail_size}x#{thumbnail_size}+0+0" + img.quality 92 end end end end