Module: Asciidoctor::Diagram::GIF

Defined in:
lib/asciidoctor-diagram/util/gif.rb

Constant Summary collapse

GIF87A_SIGNATURE =
'GIF87a'.force_encoding(Encoding::ASCII_8BIT)
GIF89A_SIGNATURE =
'GIF89a'.force_encoding(Encoding::ASCII_8BIT)

Class Method Summary collapse

Class Method Details

.post_process_image(data, optimise) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/asciidoctor-diagram/util/gif.rb', line 10

def self.post_process_image(data, optimise)
  bio = BinaryIO.new(data)
  gif_signature = bio.read_string(6)
  raise "Invalid GIF signature" unless gif_signature == GIF87A_SIGNATURE || gif_signature == GIF89A_SIGNATURE

  width = bio.read_uint16_le
  height = bio.read_uint16_le
  [data, width, height]
end