Class EXIFR::JPEG
In: lib/exifr/jpeg.rb
Parent: Object

JPEG decoder

Examples

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

Methods

exif?   method_missing   new   thumbnail   to_hash  

External Aliases

instance_methods -> instance_methods_without_jpeg_extras

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

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

[Source]

# 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

Public Instance methods

Returns true when EXIF data is available.

[Source]

# File lib/exifr/jpeg.rb, line 39
    def exif?
      !exif.nil?
    end

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

[Source]

# File lib/exifr/jpeg.rb, line 57
    def method_missing(method, *args)
      super unless args.empty?
      super unless TIFF::TAGS.include?(method.to_s)
      @exif.send method if @exif
    end

Return thumbnail data when available.

[Source]

# File lib/exifr/jpeg.rb, line 44
    def thumbnail
      @exif && @exif.jpeg_thumbnails && @exif.jpeg_thumbnails.first
    end

Get a hash presentation of the image.

[Source]

# 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

[Validate]