Search code examples
ruby-on-railspaperclipimage-rotation

Disable auto rotate in paperclip


I'm using Paperclip in my project but some of my users are complaining that it's incorrectly rotating some images.

For some reasons I can't even imagine I figured it out that some files are with wrong exif orientation attributes. I was looking and I saw that paperclip calls ImageMagick by default using -auto-orient. I saw that the Thumbnail processor has an option to turn auto-orient on or off.

But I couldn't find a way to pass this to the Processor.

This is the code I have:

  has_attached_file :photo,
    styles: { :square => "400x400#" }

Does anyone now how to do that?

Thanks!


Solution

  • In the end I created a new processor which extends from the paperclip default Thumbnail processor to send the correct options.

    class WithouAutoOrientProcessor < Paperclip::Thumbnail
      def initialize(file, options = {}, attachment = nil)
        options[:auto_orient] = false
        super
      end
    end
    

    And in the model I added

      has_attached_file :photo,
        styles: { :square => "400x400#" },
        processors: [:WithouAutoOrientProcessor]