Class: EXIFR::JPEG
- Inherits:
-
Object
- Object
- EXIFR::JPEG
- Defined in:
- lib/exifr/jpeg.rb
Overview
Defined Under Namespace
Classes: Reader
Instance Attribute Summary collapse
-
#app1s ⇒ Object
readonly
raw APP1 frames.
-
#bits ⇒ Object
readonly
number of bits per ??.
-
#comment ⇒ Object
readonly
comment; a string if one comment found, an array if more, otherwise
nil
. -
#exif ⇒ Object
readonly
EXIF data if available.
-
#exif_data ⇒ Object
readonly
raw EXIF data.
-
#height ⇒ Object
readonly
image height.
-
#width ⇒ Object
readonly
image width.
Class Method Summary collapse
-
.instance_methods(include_super = true) ⇒ Object
:nodoc:.
- .instance_methods_without_jpeg_extras ⇒ Object
Instance Method Summary collapse
-
#exif? ⇒ Boolean
Returns
true
when EXIF data is available. -
#initialize(file, load_thumbnails: true) ⇒ JPEG
constructor
file
is a filename or an IO object. -
#method_missing(method, *args) ⇒ Object
Dispatch to EXIF.
-
#methods(regular = true) ⇒ Object
:nodoc:.
-
#respond_to?(method, include_all = false) ⇒ Boolean
:nodoc:.
-
#thumbnail ⇒ Object
Return thumbnail data when available.
-
#to_hash ⇒ Object
Get a hash presentation of the image.
Constructor Details
#initialize(file, load_thumbnails: true) ⇒ JPEG
file
is a filename or an IO object. Hint: use StringIO when working with slurped data like blobs.
32 33 34 35 36 37 38 |
# File 'lib/exifr/jpeg.rb', line 32 def initialize(file, load_thumbnails: true) if file.kind_of? String File.open(file, 'rb') { |io| examine(io, load_thumbnails: load_thumbnails) } else examine(file.dup, load_thumbnails: load_thumbnails) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Dispatch to EXIF. When no EXIF data is available but the method
does exist for EXIF data nil
will be returned.
59 60 61 62 63 |
# File 'lib/exifr/jpeg.rb', line 59 def method_missing(method, *args) super unless args.empty? super unless methods.include?(method) @exif.send method if defined?(@exif) && @exif end |
Instance Attribute Details
#app1s ⇒ Object (readonly)
raw APP1 frames
29 30 31 |
# File 'lib/exifr/jpeg.rb', line 29 def app1s @app1s end |
#bits ⇒ Object (readonly)
number of bits per ??
20 21 22 |
# File 'lib/exifr/jpeg.rb', line 20 def bits @bits end |
#comment ⇒ Object (readonly)
comment; a string if one comment found, an array if more, otherwise nil
23 24 25 |
# File 'lib/exifr/jpeg.rb', line 23 def comment @comment end |
#exif ⇒ Object (readonly)
EXIF data if available
25 26 27 |
# File 'lib/exifr/jpeg.rb', line 25 def exif @exif end |
#exif_data ⇒ Object (readonly)
raw EXIF data
27 28 29 |
# File 'lib/exifr/jpeg.rb', line 27 def exif_data @exif_data end |
#height ⇒ Object (readonly)
image height
16 17 18 |
# File 'lib/exifr/jpeg.rb', line 16 def height @height end |
#width ⇒ Object (readonly)
image width
18 19 20 |
# File 'lib/exifr/jpeg.rb', line 18 def width @width end |
Class Method Details
.instance_methods(include_super = true) ⇒ Object
:nodoc:
79 80 81 |
# File 'lib/exifr/jpeg.rb', line 79 def instance_methods(include_super = true) # :nodoc: instance_methods_without_jpeg_extras(include_super) + TIFF::TAGS << :gps end |
.instance_methods_without_jpeg_extras ⇒ Object
78 |
# File 'lib/exifr/jpeg.rb', line 78 alias instance_methods_without_jpeg_extras instance_methods |
Instance Method Details
#exif? ⇒ Boolean
Returns true
when EXIF data is available.
41 42 43 |
# File 'lib/exifr/jpeg.rb', line 41 def exif? !exif.nil? end |
#methods(regular = true) ⇒ Object
:nodoc:
69 70 71 72 73 74 75 |
# File 'lib/exifr/jpeg.rb', line 69 def methods(regular=true) # :nodoc: if regular super + TIFF::TAGS << :gps else super end end |
#respond_to?(method, include_all = false) ⇒ Boolean
:nodoc:
65 66 67 |
# File 'lib/exifr/jpeg.rb', line 65 def respond_to?(method, include_all = false) # :nodoc: super || methods.include?(method) || (include_all && private_methods.include?(method)) end |
#thumbnail ⇒ Object
Return thumbnail data when available.
46 47 48 |
# File 'lib/exifr/jpeg.rb', line 46 def thumbnail defined?(@exif) && @exif && @exif.jpeg_thumbnails && @exif.jpeg_thumbnails.first end |
#to_hash ⇒ Object
Get a hash presentation of the image.
51 52 53 54 55 |
# File 'lib/exifr/jpeg.rb', line 51 def to_hash h = {:width => width, :height => height, :bits => bits, :comment => comment} h.merge!(exif) if exif? h end |