module CarrierWave::MiniMagick
def resize_and_pad(width, height, background=:transparent, gravity='Center', combine_options: {}, &block)
[MiniMagick::Image] additional manipulations to perform
=== Yields
[combine_options (Hash)] additional ImageMagick options to apply before resizing
[gravity (String)] how to position the image
[background (String, :transparent)] the color of the background as a hexcode, like "#ff45de"
[height (Integer)] the height to scale the image to
[width (Integer)] the width to scale the image to
=== Parameters
for gravity options.
See http://www.imagemagick.org/script/command-line-options.php#gravity
white for jpeg).
with the given color, which defaults to transparent (for gif and png,
the original aspect ratio. If necessary, will pad the remaining area
Resize the image to fit within the specified dimensions while retaining
#
def resize_and_pad(width, height, background=:transparent, gravity='Center', combine_options: {}, &block) width, height = resolve_dimensions(width, height) minimagick!(block) do |builder| builder.resize_and_pad(width, height, background: background, gravity: gravity) .apply(combine_options) end end