我有一个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
基本上,我想要两件事:
然而,好像水印处理在创建缩略图之前就已经发生了,有什么方法吗?
答案 0 :(得分:0)
事实证明这是不可能的。对原始版本的任何处理都将影响所有versions
。
唯一的方法是保持原始版本的清洁并从中创建2个版本:version :thumb
和version :watermarked
。