Sha256: e7c64710872d6fd41c6d7d75829c5219028b40111ef8b7986e9eae938c5b4ab5
Contents?: true
Size: 972 Bytes
Versions: 1
Compression:
Stored size: 972 Bytes
Contents
# encoding: utf-8 require 'mini_magick' module TBird class Processor attr_reader :image def initialize(file_blob) @file_blob = file_blob @image = MiniMagick::Image.read(file_blob) @tempfile = Tempfile.new(SecureRandom.uuid) end def process(&block) image.combine_options do |img| block.call(img) if block_given? end write_to_file end def write_to_file image.write @tempfile @tempfile end def original @file_blob end def resize(size) process do |img| img.resize size end end 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
t_bird-0.0.5 | lib/t_bird/processor.rb |