Class: Dimensions::ExifScanner
- Includes:
- TiffScanning
- Defined in:
- lib/dimensions/exif_scanner.rb
Constant Summary collapse
- ORIENTATION_TAG =
0x0112
- ORIENTATIONS =
[ :top_left, :top_right, :bottom_right, :bottom_left, :left_top, :right_top, :right_bottom, :left_bottom ]
Instance Attribute Summary collapse
-
#orientation ⇒ Object
readonly
Returns the value of attribute orientation.
Attributes inherited from Scanner
Instance Method Summary collapse
-
#initialize(data) ⇒ ExifScanner
constructor
A new instance of ExifScanner.
- #scan ⇒ Object
- #valid_orientation?(value) ⇒ Boolean
Methods included from TiffScanning
#read_integer_value, #scan_and_skip_to_offset, #scan_endianness, #scan_header, #scan_ifd, #scan_tag_mark
Methods inherited from Scanner
#advance, #big!, #little!, #raise_scan_error, #read, #read_char, #read_data, #read_long, #read_short, #skip_to
Constructor Details
#initialize(data) ⇒ ExifScanner
Returns a new instance of ExifScanner.
22 23 24 25 |
# File 'lib/dimensions/exif_scanner.rb', line 22 def initialize(data) @orientation = nil super end |
Instance Attribute Details
#orientation ⇒ Object (readonly)
Returns the value of attribute orientation.
20 21 22 |
# File 'lib/dimensions/exif_scanner.rb', line 20 def orientation @orientation end |
Instance Method Details
#scan ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dimensions/exif_scanner.rb', line 27 def scan scan_header scan_ifd do |tag| if tag == ORIENTATION_TAG value = read_integer_value if valid_orientation?(value) @orientation = ORIENTATIONS[value - 1] end end end @orientation end |
#valid_orientation?(value) ⇒ Boolean
42 43 44 |
# File 'lib/dimensions/exif_scanner.rb', line 42 def valid_orientation?(value) (1..ORIENTATIONS.length).include?(value) end |