From 189bcbfc047dd7fe003cd2ac6e71724784c9de48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janko=20Marohni=C4=87?= Date: Thu, 8 Sep 2016 12:09:49 +0800 Subject: [PATCH] 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. --- lib/image_processing/mini_magick.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/image_processing/mini_magick.rb b/lib/image_processing/mini_magick.rb index 40ca414..bdef31c 100644 --- a/lib/image_processing/mini_magick.rb +++ b/lib/image_processing/mini_magick.rb @@ -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