Class: ZIMG::JPEG::ECS

Inherits:
Chunk show all
Defined in:
lib/zimg/jpeg/chunks.rb

Overview

Its length is unknown in advance, nor defined in the file. The only way to get its length is to either decode it or to fast-forward over it: just scan forward for a FF byte. If it’s a restart marker (followed by D0 - D7) or a data FF (followed by 00), continue.

Instance Attribute Summary

Attributes inherited from Chunk

#data, #marker, #size

Instance Method Summary collapse

Methods inherited from Chunk

#crc, #inspect, #type

Methods inherited from Chunk

#cli_color

Constructor Details

#initialize(io) ⇒ ECS

rubocop:disable Lint/MissingSuper



305
306
307
308
309
310
311
312
# File 'lib/zimg/jpeg/chunks.rb', line 305

def initialize(io) # rubocop:disable Lint/MissingSuper
  @data = io.read
  if (pos = @data.index(/\xff[^\x00\xd0-\xd7]/))
    io.seek(pos - @data.size, :CUR) # seek back
    @data = @data[0, pos]
  end
  @size = @data.size
end

Instance Method Details

#export(*_args) ⇒ Object



314
315
316
# File 'lib/zimg/jpeg/chunks.rb', line 314

def export *_args
  @data
end