Class EXIFR::TIFF
In: lib/exifr/tiff.rb
Parent: Object

TIFF decoder

Date properties

The properties :date_time, :date_time_original, :date_time_digitized coerced into Time objects.

Orientation

The property :orientation describes the subject rotated and/or mirrored in relation to the camera. It is translated to one of the following instances:

  • TopLeftOrientation
  • TopRightOrientation
  • BottomRightOrientation
  • BottomLeftOrientation
  • LeftTopOrientation
  • RightTopOrientation
  • RightBottomOrientation
  • LeftBottomOrientation

These instances of Orientation have two methods:

  • to_i; return the original integer
  • transform_rmagick(image); transforms the given RMagick::Image to a viewable version

Examples

  EXIFR::TIFF.new('DSC_0218.TIF').width           # => 3008
  EXIFR::TIFF.new('DSC_0218.TIF')[1].width        # => 160
  EXIFR::TIFF.new('DSC_0218.TIF').model           # => "NIKON D1X"
  EXIFR::TIFF.new('DSC_0218.TIF').date_time       # => Tue May 23 19:15:32 +0200 2006
  EXIFR::TIFF.new('DSC_0218.TIF').exposure_time   # => Rational(1, 100)
  EXIFR::TIFF.new('DSC_0218.TIF').orientation     # => EXIFR::TIFF::Orientation

Methods

[]   each   height   method_missing   new   size   to_hash   width  

Included Modules

Enumerable

Classes and Modules

Class EXIFR::TIFF::Orientation

Constants

TAGS = ([TAG_MAPPING.keys, TAG_MAPPING.values.map{|v|v.values}].flatten.uniq - IFD_TAGS).map{|v|v.to_s}   Names for all recognized TIFF fields.

External Aliases

instance_methods -> instance_methods_without_tiff_extras

Attributes

jpeg_thumbnails  [R]  JPEG thumbnails

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/tiff.rb, line 313
    def initialize(file)
      data = Data.new(file)

      @ifds = [IFD.new(data)]
      while ifd = @ifds.last.next
        break if @ifds.find{|i| i.offset == ifd.offset}
        @ifds << ifd
      end

      @jpeg_thumbnails = @ifds.map do |ifd|
        if ifd.jpeg_interchange_format && ifd.jpeg_interchange_format_length
          start, length = ifd.jpeg_interchange_format, ifd.jpeg_interchange_format_length
          data[start..(start + length)]
        end
      end.compact
    end

Public Instance methods

Get index image.

[Source]

# File lib/exifr/tiff.rb, line 341
    def [](index)
      index.is_a?(Symbol) ? to_hash[index] : @ifds[index]
    end

Yield for each image.

[Source]

# File lib/exifr/tiff.rb, line 336
    def each
      @ifds.each { |ifd| yield ifd }
    end

Convenience method to access image height.

[Source]

# File lib/exifr/tiff.rb, line 379
    def height; @ifds.first.height; end

Dispatch to first image.

[Source]

# File lib/exifr/tiff.rb, line 346
    def method_missing(method, *args)
      super unless args.empty?

      if @ifds.first.respond_to?(method)
        @ifds.first.send(method)
      elsif TAGS.include?(method.to_s)
        @ifds.first.to_hash[method]
      else
        super
      end
    end

Number of images.

[Source]

# File lib/exifr/tiff.rb, line 331
    def size
      @ifds.size
    end

Get a hash presentation of the (first) image.

[Source]

# File lib/exifr/tiff.rb, line 382
    def to_hash; @ifds.first.to_hash; end

Convenience method to access image width.

[Source]

# File lib/exifr/tiff.rb, line 376
    def width; @ifds.first.width; end

[Validate]