Maintain transparent background in #resize_to_fill

When using this method on a PNG image, previously it would loose
transparency. This is because the "-extent" ImageMagick option sets a
background color. We should explicitly set the background color to
transparent, it seems to work for CarrierWave.

See https://github.com/refile/refile-mini_magick/issues/11.
This commit is contained in:
Janko Marohnić
2016-09-08 12:09:49 +08:00
parent 7b80d7194c
commit 189bcbfc04
+1
View File
@@ -110,6 +110,7 @@ module ImageProcessing
yield cmd if block_given?
cmd.resize "#{width}x#{height}^"
cmd.gravity gravity
cmd.background "rgba(255,255,255,0.0)" # transparent
cmd.extent "#{width}x#{height}"
end
end