我有 Rails 图像上传器的以下代码:
class PhotoUploader < BaseUploader
...
# Create different versions of your uploaded files:
version :thumb do
process :resize_to_fill => [80, 80]
end
# Process files as they are uploaded:
process resize_to_fit: [618, 412]
process convert: 'png'
process :watermark
process convert: 'jpg'
def watermark
manipulate! do |img|
logo = Magick::Image.read("#{Rails.root}/app/assets/images/watermark.png").first
img = img.composite(logo, Magick::NorthEastGravity, 0, 20, Magick::OverCompositeOp)
end
end
end
基本上,我想要两件事:
- 为原始图像添加水印
- 创建原始图像的缩略图(不带水印)
但是,水印处理似乎是在创建缩略图之前进行的,有什么办法可以解决这个问题吗?