class EXIFR::JPEG

JPEG decoder

Examples

EXIFR::JPEG.new('IMG_3422.JPG').width         # -> 2272
EXIFR::JPEG.new('IMG_3422.JPG').exif.model    # -> "Canon PowerShot G3"

Attributes

app1s[R]

raw APP1 frames

comment[R]

comment; a string if one comment found, an array if more, otherwise nil

exif[R]

EXIF data if available

height[R]

image height

width[R]

image width

Public Class Methods

new(file) click to toggle source

file is a filename or an IO object. Hint: use StringIO when working with slurped data like blobs.

# File lib/exifr/jpeg.rb, line 32
def initialize(file)
  if file.kind_of? String
    File.open(file, 'rb') { |io| examine(io) }
  else
    examine(file.dup)
  end
end

Public Instance Methods

exif?() click to toggle source

Returns true when EXIF data is available.

# File lib/exifr/jpeg.rb, line 41
def exif?
  !exif.nil?
end
method_missing(method, *args) click to toggle source

Dispatch to EXIF. When no EXIF data is available but the method does exist for EXIF data nil will be returned.

Calls superclass method
# 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
thumbnail() click to toggle source

Return thumbnail data when available.

# File lib/exifr/jpeg.rb, line 46
def thumbnail
  defined?(@exif) && @exif && @exif.jpeg_thumbnails && @exif.jpeg_thumbnails.first
end
to_hash() click to toggle source

Get a hash presentation of the image.

# 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