Sha256: 9be81bd608b41e21825f4c2e3ad7f9294a3dfb36318f9a62fc9a4ad1962d2768
Contents?: true
Size: 713 Bytes
Versions: 5
Compression:
Stored size: 713 Bytes
Contents
require 'file_data/file_types/jpeg' require_relative 'exif_stream' module FileData # Retrieves an ExifStream from a jpeg stream class ExifJpeg APP1_BYTES = [255, 225].freeze EXIF_ID = "Exif\0\0".bytes.to_a.freeze def initialize(stream) @stream = stream end def exif ExifStream.new(@stream) if seek_exif end private def seek_exif Jpeg.each_section(@stream) .select { |section| exif_section?(section) } .first end def exif_section?(section) section.marker == APP1_BYTES && read_exif_id(section) end def read_exif_id(section) section.content_stream.each_byte.take(EXIF_ID.size) == EXIF_ID end end end
Version data entries
5 entries across 5 versions & 1 rubygems