class FileData::ExifJpeg

Retrieves an ExifStream from a jpeg stream

Constants

APP1_BYTES
EXIF_ID

Public Class Methods

new(stream) click to toggle source
# File lib/file_data/formats/exif/exif_jpeg.rb, line 10
def initialize(stream)
  @stream = stream
end

Public Instance Methods

exif() click to toggle source
# File lib/file_data/formats/exif/exif_jpeg.rb, line 14
def exif
  ExifStream.new(@stream) if seek_exif
end

Private Instance Methods

exif_section?(section) click to toggle source
# File lib/file_data/formats/exif/exif_jpeg.rb, line 26
def exif_section?(section)
  section.marker == APP1_BYTES && read_exif_id(section)
end
read_exif_id(section) click to toggle source
# File lib/file_data/formats/exif/exif_jpeg.rb, line 30
def read_exif_id(section)
  section.content_stream.each_byte.take(EXIF_ID.size) == EXIF_ID
end
seek_exif() click to toggle source
# File lib/file_data/formats/exif/exif_jpeg.rb, line 20
def seek_exif
  Jpeg.each_section(@stream)
      .select { |section| exif_section?(section) }
      .first
end