Method: CarrierWave::RMagick#resize_to_fill

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

#resize_to_fill(width, height, gravity = ::Magick::CenterGravity) ⇒ Object

From the RMagick documentation: “Resize the image to fit within the specified dimensions while retaining the aspect ratio of the original image. If necessary, crop the image in the larger dimension.”

See even www.imagemagick.org/RMagick/doc/image3.html#resize_to_fill

Parameters

width (Integer)

the width to scale the image to

height (Integer)

the height to scale the image to

Yields

Magick::Image

additional manipulations to perform



201
202
203
204
205
206
207
208
209
# File 'lib/carrierwave/processing/rmagick.rb', line 201

def resize_to_fill(width, height, gravity=::Magick::CenterGravity)
  width = dimension_from width
  height = dimension_from height
  manipulate! do |img|
    img.crop_resized!(width, height, gravity)
    img = yield(img) if block_given?
    img
  end
end