Class: Attachs::Processors::Image

Inherits:
Base
  • Object
show all
Defined in:
lib/attachs/processors/image.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Attachs::Processors::Base

Instance Method Details

#process(destination_path, geometry) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/attachs/processors/image.rb', line 5

def process(destination_path, geometry)
  if geometry
    size, suffix = geometry.scan(/([^!#]+)(!|#)?$/).flatten
    strategy = detect_strategy(suffix)
    new_width, new_height = size.split('x').map(&:to_i)
    resize new_width, new_height, strategy, destination_path
  else
    Console.convert source_path, destination_path
  end
end