in Web & Tech

Make CarrierWave respect Exif orientation

# config/initializers/carrierwave_initializer.rb
module CarrierWave
  module RMagick
    # Rotates the image based on the EXIF Orientation
    def fix_exif_rotation
      manipulate! do |img|
        img.auto_orient!
        img = yield(img) if block_given?
        img
      end
    end
  end
end

With this initializer we can add process :fix_exif_rotation to our uploader model.

Found in this great blog post by Mario Visic, which, by the way, also shows how to change jpeg quality.

Write a Comment

Comment

  • Related Content by Tag