samedi 25 novembre 2017

Minimagic remove alpha doesn't work (Windows 10). Rails 5 with MiniMagic

I have an app Rails 5 with Carrierwave for uploading images and MiniMagic. I want when the image is uploaded to convert to .jpg and if it is transparent, to set white background. I know that Minimagic is a wrapper for ImageMagic and I have installed it in Windows.

Everything works fine in Linux, but in Windows removing alpha channel does not work. This is my uploader (CarrierWave):

version :thumb do
  process :process_image
end

def process_image
  manipulate! do |image|
    image.combine_options do |img|
      img.alpha 'remove'
      img.trim
      img.resize      "50x50>"
      img.resize      "50x50<"
    end
    image.format 'jpg'
  end
end

In Linux works fine (set white background and removes alpha channel), but in Windows it just doesn't upload the image, if I am using img.alpha 'remove'. Without it, it upload image, resize it, convert it to jpg, but with black background, because alpha channel is not removed.

How to remove alpha channel of the image in Windows with Minimagic and ImageMagic ?

Aucun commentaire:

Enregistrer un commentaire