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) ⇒ JPEG
constructor
file
is a filename or an IO object. -
#method_missing(method, *args) ⇒ Object
Dispatch to EXIF.
-
#methods ⇒ 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) ⇒ JPEG
file
is a filename or an IO object. Hint: use StringIO when working with slurped data like blobs.
31 32 33 34 35 36 37 |
# File 'lib/exifr/jpeg.rb', line 31 def initialize(file) if file.kind_of? String File.open(file, 'rb') { |io| examine(io) } else examine(file.dup) 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.
58 59 60 61 62 |
# File 'lib/exifr/jpeg.rb', line 58 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
28 29 30 |
# File 'lib/exifr/jpeg.rb', line 28 def app1s @app1s end |
#bits ⇒ Object (readonly)
number of bits per ??
19 20 21 |
# File 'lib/exifr/jpeg.rb', line 19 def bits @bits end |
#comment ⇒ Object (readonly)
comment; a string if one comment found, an array if more, otherwise nil
22 23 24 |
# File 'lib/exifr/jpeg.rb', line 22 def comment @comment end |
#exif ⇒ Object (readonly)
EXIF data if available
24 25 26 |
# File 'lib/exifr/jpeg.rb', line 24 def exif @exif end |
#exif_data ⇒ Object (readonly)
raw EXIF data
26 27 28 |
# File 'lib/exifr/jpeg.rb', line 26 def exif_data @exif_data end |
#height ⇒ Object (readonly)
image height
15 16 17 |
# File 'lib/exifr/jpeg.rb', line 15 def height @height end |
#width ⇒ Object (readonly)
image width
17 18 19 |
# File 'lib/exifr/jpeg.rb', line 17 def width @width end |
Class Method Details
.instance_methods(include_super = true) ⇒ Object
:nodoc:
74 75 76 |
# File 'lib/exifr/jpeg.rb', line 74 def instance_methods(include_super = true) # :nodoc: instance_methods_without_jpeg_extras(include_super) + TIFF::TAGS << :gps end |
.instance_methods_without_jpeg_extras ⇒ Object
73 |
# File 'lib/exifr/jpeg.rb', line 73 alias instance_methods_without_jpeg_extras instance_methods |
Instance Method Details
#exif? ⇒ Boolean
Returns true
when EXIF data is available.
40 41 42 |
# File 'lib/exifr/jpeg.rb', line 40 def exif? !exif.nil? end |
#methods ⇒ Object
:nodoc:
68 69 70 |
# File 'lib/exifr/jpeg.rb', line 68 def methods # :nodoc: super + TIFF::TAGS << :gps end |
#respond_to?(method, include_all = false) ⇒ Boolean
:nodoc:
64 65 66 |
# File 'lib/exifr/jpeg.rb', line 64 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.
45 46 47 |
# File 'lib/exifr/jpeg.rb', line 45 def thumbnail defined?(@exif) && @exif && @exif.jpeg_thumbnails && @exif.jpeg_thumbnails.first end |
#to_hash ⇒ Object
Get a hash presentation of the image.
50 51 52 53 54 |
# File 'lib/exifr/jpeg.rb', line 50 def to_hash h = {:width => width, :height => height, :bits => bits, :comment => comment} h.merge!(exif) if exif? h end |