Class: FormatParser::EXIFParser
- Inherits:
-
Object
- Object
- FormatParser::EXIFParser
- Includes:
- IOUtils
- Defined in:
- lib/parsers/exif_parser.rb
Defined Under Namespace
Classes: IOExt
Constant Summary collapse
- ORIENTATIONS =
[ :top_left, :top_right, :bottom_right, :bottom_left, :left_top, :right_top, :right_bottom, :left_bottom ]
Instance Attribute Summary collapse
-
#exif_data ⇒ Object
Returns the value of attribute exif_data.
-
#height ⇒ Object
Returns the value of attribute height.
-
#orientation ⇒ Object
Returns the value of attribute orientation.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(io_blob_with_exif_data) ⇒ EXIFParser
constructor
A new instance of EXIFParser.
- #orientation_parser(raw_exif_data) ⇒ Object
- #scan_image_tiff ⇒ Object
- #valid_orientation?(value) ⇒ Boolean
Methods included from IOUtils
Constructor Details
#initialize(io_blob_with_exif_data) ⇒ EXIFParser
Returns a new instance of EXIFParser.
50 51 52 53 54 55 56 |
# File 'lib/parsers/exif_parser.rb', line 50 def initialize(io_blob_with_exif_data) @exif_io = IOExt.new(io_blob_with_exif_data) @exif_data = nil @orientation = nil @height = nil @width = nil end |
Instance Attribute Details
#exif_data ⇒ Object
Returns the value of attribute exif_data.
37 38 39 |
# File 'lib/parsers/exif_parser.rb', line 37 def exif_data @exif_data end |
#height ⇒ Object
Returns the value of attribute height.
37 38 39 |
# File 'lib/parsers/exif_parser.rb', line 37 def height @height end |
#orientation ⇒ Object
Returns the value of attribute orientation.
37 38 39 |
# File 'lib/parsers/exif_parser.rb', line 37 def orientation @orientation end |
#width ⇒ Object
Returns the value of attribute width.
37 38 39 |
# File 'lib/parsers/exif_parser.rb', line 37 def width @width end |
Instance Method Details
#orientation_parser(raw_exif_data) ⇒ Object
68 69 70 71 |
# File 'lib/parsers/exif_parser.rb', line 68 def orientation_parser(raw_exif_data) value = raw_exif_data.orientation.to_i @orientation = ORIENTATIONS[value - 1] if valid_orientation?(value) end |
#scan_image_tiff ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/parsers/exif_parser.rb', line 58 def scan_image_tiff raw_exif_data = EXIFR::TIFF.new(@exif_io) # For things that we don't yet have a parser for # we make the raw exif result available @exif_data = raw_exif_data @orientation = orientation_parser(raw_exif_data) @width = @exif_data.width @height = @exif_data.height end |
#valid_orientation?(value) ⇒ Boolean
73 74 75 |
# File 'lib/parsers/exif_parser.rb', line 73 def valid_orientation?(value) (1..ORIENTATIONS.length).include?(value) end |