Class: Exif::Fujifilm

Inherits:
Object
  • Object
show all
Defined in:
lib/exifparser/makernote/fujifilm.rb

Instance Method Summary collapse

Constructor Details

#initialize(fin, tiff_origin, dataPos, byteOrder_module) ⇒ Fujifilm

Returns a new instance of Fujifilm.



356
357
358
359
360
361
362
# File 'lib/exifparser/makernote/fujifilm.rb', line 356

def initialize(fin, tiff_origin, dataPos, byteOrder_module)
  @fin = fin
  @tiffHeader0 = tiff_origin
  @dataPos = dataPos
  @byteOrder_module = Utils::Decode::Intel  # force Intel
  self.extend @byteOrder_module
end

Instance Method Details

#scan_IFDObject



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'lib/exifparser/makernote/fujifilm.rb', line 364

def scan_IFD
  #
  # Fujifilm MakerNote starts from 8 byte from the origin
  #
  @fin.pos = @dataPos + 8
  offset = decode_ushort(fin_read_n(2))
  @fin.pos = @dataPos + offset
  #
  # get the number of tags
  #
  numDirs = decode_ushort(fin_read_n(2))
  #
  # now scan them
  #
  1.upto(numDirs) {
    curpos_tag = @fin.pos
    tag = parseTagID(fin_read_n(2))
    tagclass = Tag.find(tag.hex, Tag::FujifilmIFDTable)
    unit, formatter = Tag::Format::Unit[decode_ushort(fin_read_n(2))]
    count = decode_ulong(fin_read_n(4))
    tagdata = fin_read_n(4)

    obj = tagclass.new(tag, "MakerNote", count)
    obj.extend formatter, @byteOrder_module
    obj.pos = curpos_tag
    if unit * count > 4
      curpos = @fin.pos
      begin
        @fin.pos = @dataPos + decode_ulong(tagdata)
        obj.dataPos = @fin.pos
        obj.data = fin_read_n(unit*count)
      ensure
        @fin.pos = curpos
      end
    else
      obj.dataPos = @fin.pos - 4
      obj.data = tagdata
    end
    obj.processData
    yield obj
  }
end