lib/carrierwave/processing/mini_magick.rb in carrierwave-0.5.8 vs lib/carrierwave/processing/mini_magick.rb in carrierwave-0.6.0
- old
+ new
@@ -68,12 +68,12 @@
def resize_to_fit(width, height)
process :resize_to_fit => [width, height]
end
- def resize_to_fill(width, height)
- process :resize_to_fill => [width, height]
+ def resize_to_fill(width, height, gravity='Center')
+ process :resize_to_fill => [width, height, gravity]
end
def resize_and_pad(width, height, background=:transparent, gravity=::Magick::CenterGravity)
process :resize_and_pad => [width, height, background, gravity]
end
@@ -156,10 +156,11 @@
#
# === Parameters
#
# [width (Integer)] the width to scale the image to
# [height (Integer)] the height to scale the image to
+ # [gravity (String)] the current gravity suggestion (default: 'Center'; options: 'NorthWest', 'North', 'NorthEast', 'West', 'Center', 'East', 'SouthWest', 'South', 'SouthEast')
#
# === Yields
#
# [MiniMagick::Image] additional manipulations to perform
#
@@ -172,10 +173,11 @@
cols = (scale * (cols + 0.5)).round
rows = (scale * (rows + 0.5)).round
cmd.resize "#{cols}x#{rows}"
end
cmd.gravity gravity
+ cmd.background "rgba(255,255,255,0.0)"
cmd.extent "#{width}x#{height}" if cols != width || rows != height
end
img = yield(img) if block_given?
img
end
@@ -204,10 +206,10 @@
def resize_and_pad(width, height, background=:transparent, gravity='Center')
manipulate! do |img|
img.combine_options do |cmd|
cmd.thumbnail "#{width}x#{height}>"
if background == :transparent
- cmd.background "rgba(0, 0, 0, 0.0)"
+ cmd.background "rgba(255, 255, 255, 0.0)"
else
cmd.background background
end
cmd.gravity gravity
cmd.extent "#{width}x#{height}"