class FileData::ExifReader

Returns the exif data from a jpeg file

Public Class Methods

new(exif_stream) click to toggle source
# File lib/file_data/formats/exif/exif_reader.rb, line 9
def initialize(exif_stream)
  @exif_stream = exif_stream
end

Public Instance Methods

all_data() click to toggle source
# File lib/file_data/formats/exif/exif_reader.rb, line 21
def all_data
  exif_tags_internal(0, 1)
end
image_data_only() click to toggle source
# File lib/file_data/formats/exif/exif_reader.rb, line 13
def image_data_only
  exif_tags_internal(0).image
end
only_image_tag(tag_id) click to toggle source
# File lib/file_data/formats/exif/exif_reader.rb, line 25
def only_image_tag(tag_id)
  exif_tag_internal(0, tag_id)
end
only_thumbnail_tag(tag_id) click to toggle source
# File lib/file_data/formats/exif/exif_reader.rb, line 29
def only_thumbnail_tag(tag_id)
  exif_tag_internal(1, tag_id)
end
tags(*ifds_to_include) click to toggle source
# File lib/file_data/formats/exif/exif_reader.rb, line 33
def tags(*ifds_to_include)
  return [] if @exif_stream.nil?

  @exif_stream.read_header
  ExifTagReader.new(@exif_stream, *ifds_to_include).tags
end
thumbnail_data_only() click to toggle source
# File lib/file_data/formats/exif/exif_reader.rb, line 17
def thumbnail_data_only
  exif_tags_internal(1).thumbnail
end

Private Instance Methods

exif_tag_internal(ifd_index, tag_to_find) click to toggle source
# File lib/file_data/formats/exif/exif_reader.rb, line 48
def exif_tag_internal(ifd_index, tag_to_find)
  @exif_stream.read_tag_value if find_tag(ifd_index, tag_to_find)
end
exif_tags_internal(*ifds_to_include) click to toggle source
# File lib/file_data/formats/exif/exif_reader.rb, line 42
def exif_tags_internal(*ifds_to_include)
  tags(@exif_stream, *ifds_to_include).each_with_object(ExifData.new) do |tag_info, data|
    data.add_tag(*tag_info, @exif_stream.read_tag_value)
  end
end
find_tag(ifd_index, tag_to_find) click to toggle source
# File lib/file_data/formats/exif/exif_reader.rb, line 52
def find_tag(ifd_index, tag_to_find)
  tags(@exif_stream, ifd_index).find do |_, ifd_id, tag_num|
    tag_to_find == [ifd_id, tag_num]
  end
end