-
Notifications
You must be signed in to change notification settings - Fork 1.7k
How to: Process original image
Aivils Štoss edited this page Mar 22, 2018
·
2 revisions
This uploader will process orginal image after store. It will resize image with max width 1200px. You can add this to your existing uploader and later reprocess all uploads with standard foo_model.file.recreate_versions! . It will reprocess original images too. You cannot restore original images after this.
class FileUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
after :store, :process_original
# Developer must ensure mogrify exists and available in host OS
# Replace "-resize 1200" with your settings
def process_original(new_file)
if version_name.nil?
system("mogrify -resize '1200\>' #{file.file}")
end
end
end
Please ensure system command "mogrify" exists in target OS
$ which mogrify
/usr/bin/mogrify