1

I'm having basically the same problem here:

How to remove exif from a JPG without losing image quality?

But I'm using Rails and Carrierwave. I'm not sure how Robbert's solution converts to Ruby.

Any help would greatly be appreciated! Thanks!

Community
  • 1
  • 1
JPN
  • 632
  • 12
  • 24

1 Answers1

2

From the carrierwave docs, you can add something like the following mogrify function to your uploader:

class PhotoUploader < CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick

  process :mogrify

  # ...

  def mogrify
    manipulate! do |img|
      img.format('jpg') do |c|

        # other options you may want, eg:
        # c.auto_orient

        convert.profile.+('!icc,!xmp,*')
      end
      img
    end
  end
end

which will strip the EXIF data but preserve the ICC and XMP profiles in the JPG.

ivnts
  • 36
  • 4
  • I noticed when updating my mini_magick gem to 4.2 (was 3.4) I had problems too. Try changing the two lines from my answer to this one line: `convert.profile.+('!icc,!xmp,*')` – ivnts Jul 10 '15 at 19:25
  • Do XMP profiles exist in images? I have only been able to find external xmp files that are stored alongside RAW files. – fatfrog Dec 09 '21 at 22:54
  • @fatfrog I don't have personal experience with embedding XMP metadata in images, but looking at the [XMP Wikipedia page](https://en.wikipedia.org/wiki/Extensible_Metadata_Platform#Embedding), it can be embedded in various image formats, including JPEGs. Hope that helps. – ivnts Dec 11 '21 at 19:44