Created
November 12, 2013 20:44
-
-
Save tanraya/7438337 to your computer and use it in GitHub Desktop.
Carrierwave auto orient image explained
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module CarrierWave | |
module MiniMagick | |
# Rotates the image based on the EXIF Orientation | |
# According to http://jpegclub.org/exif_orientation.html | |
def auto_orient | |
manipulate! do |image| | |
case image['EXIF:Orientation'].to_i | |
when 2 | |
image.flop | |
when 3 | |
image.rotate(180) | |
when 4 | |
image.flip | |
when 5 | |
image.transpose | |
when 6 | |
image.rotate(90) | |
when 7 | |
image.transverse | |
when 8 | |
image.rotate(270) | |
end | |
image | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the same as