Class: Udongo::ImageManipulation::ResizeToFit

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/udongo/image_manipulation/resize_to_fit.rb

Instance Method Summary collapse

Methods included from Base

#initialize

Instance Method Details

#resize(path) ⇒ Object

Resize the image to fit within the specified dimensions while retaining the original aspect ratio. The image may be shorter or narrower than specified in the smaller dimension but will not be larger than the specified values.



12
13
14
15
16
17
18
19
20
# File 'lib/udongo/image_manipulation/resize_to_fit.rb', line 12

def resize(path)
  img = MiniMagick::Image.open(@file)
  img.combine_options do |c|
    c.quality @options[:quality] if @options[:quality]
    c.resize "#{@width}x#{@height}"
  end

  img.write(path)
end