lib/parsers/tiff_parser.rb
# The TIFF format stores metadata in a flexible set of information fields
# called tags, which are stored in a header referred to as the IFD or
# Image File Directory. It is not necessarily in the same place in every image,
# so we need to do some work to scan through it and find the tags we need.
# For more information the TIFF wikipedia page is a reasonable place to start:
# https://en.wikipedia.org/wiki/TIFF
The TIFF format stores metadata in a flexible set of information fields
called tags, which are stored in a header referred to as the IFD or
Image File Directory. It is not necessarily in the same place in every image,
so we need to do some work to scan through it and find the tags we need.
The TIFF format stores metadata in a flexible set of information fields called tags which are stored in a header referred to as the IFD or Image File Directory . It is not necessarily in the same place in every image so we need to do some work to scan through it and find the tags we need .
def scan_ifd(cache, offset, endianness)
    entry_count = safe_read(cache, 4).unpack(endianness)[0]
    entry_count.times do |i|
      cache.seek(offset + 2 + (12 * i))
      tag = safe_read(cache, 4).unpack(endianness)[0]
      if tag == WIDTH_TAG
        @width = safe_read(cache, 4).unpack(endianness.upcase)[0]
      elsif tag == HEIGHT_TAG
        @height = safe_read(cache, 4).unpack(endianness.upcase)[0]
      end
    end
  end
def scan_ifd ( cache , offset , endianness ) entry_count = safe_read ( cache , 4 ) . unpack ( endianness ) [ 0 ] entry_count . times do | i | cache . seek ( offset + 2 + ( 12 * i ) ) tag = safe_read ( cache , 4 ) . unpack ( endianness ) [ 0 ] if tag == WIDTH_TAG @width = safe_read ( cache , 4 ) . unpack ( endianness . upcase ) [ 0 ] elsif tag == HEIGHT_TAG @height = safe_read ( cache , 4 ) . unpack ( endianness . upcase ) [ 0 ] end end end
The TIFF format stores metadata in a flexible set of information fields
called tags, which are stored in a header referred to as the IFD or
Image File Directory.
The TIFF format stores metadata in a flexible set of information fields called tags which are stored in a header referred to as the IFD or Image File Directory .
cache
offset
endianness