Method: CarrierWave::MiniMagick#resize_to_fit

Defined in:
lib/carrierwave/processing/mini_magick.rb

#resize_to_fit(width, height, combine_options: {}, &block) ⇒ 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.

Parameters

width (Integer)

the width to scale the image to

height (Integer)

the height to scale the image to

combine_options (Hash)

additional ImageMagick options to apply before resizing

Yields

MiniMagick::Image

additional manipulations to perform


153
154
155
156
157
158
159
160
# File 'lib/carrierwave/processing/mini_magick.rb', line 153

def resize_to_fit(width, height, combine_options: {}, &block)
  width, height = resolve_dimensions(width, height)

  minimagick!(block) do |builder|
    builder.resize_to_fit(width, height)
      .apply(combine_options)
  end
end