Method: Fleximage::Operator::Base#scale

Defined in:
lib/fleximage/operator/base.rb

#scale(size, img = @image) ⇒ Object

Scale the image, respecting aspect ratio.

Operation will happen in the main @image unless you supply the img argument to operate on instead.



127
128
129
130
131
132
133
# File 'lib/fleximage/operator/base.rb', line 127

def scale(size, img = @image)
  img.change_geometry!(size_to_xy(size).join('x')) do |cols, rows, _img|
    cols = 1 if cols < 1
    rows = 1 if rows < 1
    _img.resize!(cols, rows)
  end
end