How to remove EXIF (camera) data from image with carrierwave?
-
13-10-2019 - |
Question
Does anybody know? With paperclip there was a special config command.
Removing camera data from image keeps 25-30 Kb per file. It's very sensitive if we make a lot of versions (thumb, small...). In small images the actual size of file without this information can be 5-6 times less.
Thanks in advance!
Solution
Carrierwave is very flexible and it's possible to make own processors. With MiniMagick we can use a bunch of options of mogrify
command-line utility, one of them is strip:
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
version :small do
process :resize_to_fill => [100, 100]
process :strip
end
def strip
manipulate! do |img|
img.strip!
img = yield(img) if block_given?
img
end
end
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow