1
我有一個Rails的圖片上傳下面的代碼:CarrierWave:從未經處理的圖像創建拇指
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
基本上,我想兩兩件事:
- 添加水印原始圖像
- 創建原始圖像的縮略圖(沒有水印)
但是,它顯示爲雖然水印處理在創建縮略圖之前發生,但是有沒有辦法解決這個問題?