我试图将此命令行选项转换为在carrierwave中使用的处理器方法,但我无法让它工作。我按照我在这里看到的方法。
convert E22725-89PC.jpg -matte -fill none -fuzz 15% -opaque white result.png
这是我的 CarrierWave 上传器
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
process :remove_background => 'white'
def remove_background(color)
manipulate! do |img|
img = img.format 'png'
img = img.matte
img = img.fill 'none'
img = img.fuzz '15%'
img = img.opaque color
end
end
end