class Udongo::ImageManipulation::ResizeToLimit

Public Instance Methods

resize(path) click to toggle source

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

# File lib/udongo/image_manipulation/resize_to_limit.rb, line 13
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