Prevent automatic rotation of uploaded pictures
Ipad and iphone safari browser tries to be smart and rotates the images according to their exif:Orientation property value. In general cases we don't want that.

The easiest way is to use jhead command line utility:
$ jhead -norot <path to file>From jhead manual:
ruby
-norot     Zero out the rotation tag.  This to avoid some browsers from
                 rotating the image again after you rotated it but neglected to
                 clear the rotation tag
If you use ruby and paperclip gem, here is the ready solution:
module Paperclip
  class NoRotation < Processor
    def make
      command = "jhead"
      params = %W[-norot #{abs_path_to_file(@file)}]
      begin
        Paperclip.run(command, params.join(' '))
      rescue ArgumentError, Cocaine::CommandLineError
        raise Paperclip::Error, "There was an error removing rotation for #{@basename}"
      end
      @file
    end
    def abs_path_to_file(destination)
      File.expand_path(destination.path)
    end
  end
endAnd in the model apply the processor:
has_attached_file :picture, processors: [:no_rotation]Written by Anton Kuzmin
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
 #Ruby 
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#
 
 
 
 
