开发者

How to remove EXIF (camera) data from image with carrierwave?

开发者 https://www.devze.com 2023-02-06 01:49 出处:网络
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 (开发者_StackOverflow

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 (开发者_StackOverflow中文版thumb, small...). In small images the actual size of file without this information can be 5-6 times less.

Thanks in advance!


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


If anyone gets here and wonders why it doesn't work, it's because it should be strip, and not strip!. The method name is passed directly to ImageMagick, which does not understand strip!.

0

精彩评论

暂无评论...
验证码 换一张
取 消