Carrierwave RMagick not removing transparency in convert to jpg

不想你离开。 提交于 2019-12-02 03:26:27

There appears to be a quirk with imagemagick and order of operations when converting file types.

Full github issue can be found here: https://github.com/carrierwaveuploader/carrierwave/issues/133#issuecomment-615254

Basically manipulate is called once for every process you have. manipulate opens the current file path, makes changes then writes. Because of this it seems that any process lines that are called after the format conversion are performed on the original file, not the newly converted one.

In order to fix this, you either have to do all of your process operations within a single manipulate block or make sure that the conversion is the last process to run.

The example of this from the github issue is:

process :convert_and_scale

def convert_and_scale
  manipulate! do |img|
    img.format 'png'
    img.resize '100x32'
    img
  end
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!