Class: EXIFR::JPEG
- Inherits:
-
Object
- Object
- EXIFR::JPEG
- Defined in:
- lib/exifr/jpeg.rb
Overview
JPEG decoder
Examples
EXIFR::JPEG.new('IMG_3422.JPG').width # -> 2272
EXIFR::JPEG.new('IMG_3422.JPG').exif.model # -> "Canon PowerShot G3"
Instance Attribute Summary (collapse)
-
- (Object) app1s
readonly
raw APP1 frames.
-
- (Object) bits
readonly
number of bits per ??.
-
- (Object) comment
readonly
comment; a string if one comment found, an array if more, otherwise nil.
-
- (Object) exif
readonly
EXIF data if available.
-
- (Object) exif_data
readonly
raw EXIF data.
-
- (Object) height
readonly
image height.
-
- (Object) width
readonly
image width.
Class Method Summary (collapse)
-
+ (Object) instance_methods(include_super = true)
:nodoc:.
- + (Object) instance_methods_without_jpeg_extras
Instance Method Summary (collapse)
-
- (Boolean) exif?
Returns true when EXIF data is available.
-
- (JPEG) initialize(file)
constructor
file is a filename or an IO object.
-
- (Object) method_missing(method, *args)
Dispatch to EXIF.
-
- (Object) methods
:nodoc:.
-
- (Boolean) respond_to?(method)
:nodoc:.
-
- (Object) thumbnail
Return thumbnail data when available.
-
- (Object) to_hash
Get a hash presentation of the image.
Constructor Details
- (JPEG) initialize(file)
file is a filename or an IO object. Hint: use StringIO when working with slurped data like blobs.
30 31 32 33 34 35 36 |
# File 'lib/exifr/jpeg.rb', line 30 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
- (Object) method_missing(method, *args)
Dispatch to EXIF. When no EXIF data is available but the method does exist for EXIF data nil will be returned.
57 58 59 60 61 |
# File 'lib/exifr/jpeg.rb', line 57 def method_missing(method, *args) super unless args.empty? super unless methods.include?(method.to_s) @exif.send method if defined?(@exif) && @exif end |
Instance Attribute Details
- (Object) app1s (readonly)
raw APP1 frames
27 28 29 |
# File 'lib/exifr/jpeg.rb', line 27 def app1s @app1s end |
- (Object) bits (readonly)
number of bits per ??
18 19 20 |
# File 'lib/exifr/jpeg.rb', line 18 def bits @bits end |
- (Object) comment (readonly)
comment; a string if one comment found, an array if more, otherwise nil
21 22 23 |
# File 'lib/exifr/jpeg.rb', line 21 def comment @comment end |
- (Object) exif (readonly)
EXIF data if available
23 24 25 |
# File 'lib/exifr/jpeg.rb', line 23 def exif @exif end |
- (Object) exif_data (readonly)
raw EXIF data
25 26 27 |
# File 'lib/exifr/jpeg.rb', line 25 def exif_data @exif_data end |
- (Object) height (readonly)
image height
14 15 16 |
# File 'lib/exifr/jpeg.rb', line 14 def height @height end |
- (Object) width (readonly)
image width
16 17 18 |
# File 'lib/exifr/jpeg.rb', line 16 def width @width end |
Class Method Details
+ (Object) instance_methods(include_super = true)
:nodoc:
73 74 75 |
# File 'lib/exifr/jpeg.rb', line 73 def instance_methods(include_super = true) # :nodoc: instance_methods_without_jpeg_extras(include_super) + TIFF::TAGS << "gps" end |
+ (Object) instance_methods_without_jpeg_extras
72 |
# File 'lib/exifr/jpeg.rb', line 72 alias instance_methods_without_jpeg_extras instance_methods |
Instance Method Details
- (Boolean) exif?
Returns true when EXIF data is available.
39 40 41 |
# File 'lib/exifr/jpeg.rb', line 39 def exif? !exif.nil? end |
- (Object) methods
:nodoc:
67 68 69 |
# File 'lib/exifr/jpeg.rb', line 67 def methods # :nodoc: super + TIFF::TAGS << "gps" end |
- (Boolean) respond_to?(method)
:nodoc:
63 64 65 |
# File 'lib/exifr/jpeg.rb', line 63 def respond_to?(method) # :nodoc: super || methods.include?(method.to_s) end |
- (Object) thumbnail
Return thumbnail data when available.
44 45 46 |
# File 'lib/exifr/jpeg.rb', line 44 def thumbnail defined?(@exif) && @exif && @exif.jpeg_thumbnails && @exif.jpeg_thumbnails.first end |
- (Object) to_hash
Get a hash presentation of the image.
49 50 51 52 53 |
# File 'lib/exifr/jpeg.rb', line 49 def to_hash h = {:width => width, :height => height, :bits => bits, :comment => comment} h.merge!(exif) if exif? h end |