Class: FormatParser::JPEGParser

Inherits:
Object
  • Object
show all
Includes:
EXIFParser, IOUtils
Defined in:
lib/parsers/jpeg_parser.rb

Defined Under Namespace

Classes: InvalidStructure

Constant Summary collapse

JPEG_SOI_MARKER_HEAD =
[0xFF, 0xD8].pack('C2')
SOF_MARKERS =
[0xC0..0xC3, 0xC5..0xC7, 0xC9..0xCB, 0xCD..0xCF]
EOI_MARKER =

end of image

0xD9
SOS_MARKER =

start of stream

0xDA
APP1_MARKER =

maybe EXIF

0xE1
EXIF_MAGIC_STRING =
"Exif\0\0".b
MUST_FIND_NEXT_MARKER_WITHIN_BYTES =
1024
JPEG_MIME_TYPE =
'image/jpeg'

Constants included from EXIFParser

EXIFParser::ORIENTATIONS

Constants included from IOUtils

IOUtils::INTEGER_DIRECTIVES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EXIFParser

#exif_from_tiff_io

Methods included from IOUtils

#read_bytes, #read_fixed_point, #read_int, #safe_read, #safe_skip, #skip_bytes

Class Method Details

.call(io) ⇒ Object



21
22
23
# File 'lib/parsers/jpeg_parser.rb', line 21

def self.call(io)
  new.call(io)
end

.likely_match?(filename) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/parsers/jpeg_parser.rb', line 17

def self.likely_match?(filename)
  filename =~ /\.jpe?g$/i
end

Instance Method Details

#call(io) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/parsers/jpeg_parser.rb', line 25

def call(io)
  @buf = FormatParser::IOConstraint.new(io)
  @width             = nil
  @height            = nil
  @exif_data_frames  = []
  scan
end