Method: Magick::Image#resize_to_fill!

Defined in:
lib/rmagick_internal.rb

#resize_to_fill!(ncols, nrows = nil, gravity = CenterGravity) ⇒ Object Also known as: crop_resized!



975
976
977
978
979
980
981
982
983
# File 'lib/rmagick_internal.rb', line 975

def resize_to_fill!(ncols, nrows = nil, gravity = CenterGravity)
  nrows ||= ncols
  if ncols != columns || nrows != rows
    scale = [ncols / columns.to_f, nrows / rows.to_f].max
    resize!(scale * columns + 0.5, scale * rows + 0.5)
  end
  crop!(gravity, ncols, nrows, true) if ncols != columns || nrows != rows
  self
end