Module: Vips::Process::AutoOrient
- Defined in:
- lib/vips-process/auto-orient.rb
Constant Summary collapse
- EMPTY_STRING =
''.freeze
- EXIF_ORIENTATION =
'exif-Orientation'.freeze
- EXIF_IFD0_ORIENTATION =
'exif-ifd0-Orientation'.freeze
Instance Method Summary collapse
-
#auto_orient ⇒ Object
Read the camera EXIF data to determine orientation and adjust accordingly.
Instance Method Details
#auto_orient ⇒ Object
Read the camera EXIF data to determine orientation and adjust accordingly
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vips-process/auto-orient.rb', line 9 def auto_orient manipulate! do |image| o = image.get(EXIF_ORIENTATION).to_i rescue nil o ||= image.get(EXIF_IFD0_ORIENTATION).to_i rescue 1 case o when 1 # Do nothing, everything is peachy when 6 image.rot270 when 8 image.rot180 when 3 image.rot90 else raise('Invalid value for Orientation: ' + o.to_s) end image.set EXIF_ORIENTATION, EMPTY_STRING image.set EXIF_IFD0_ORIENTATION, EMPTY_STRING end self end |