module Asciidoctor::Diagram::GIF

@private

Constants

GIF87A_SIGNATURE
GIF89A_SIGNATURE

Public Class Methods

get_image_size(data) click to toggle source
# File lib/asciidoctor-diagram/util/gif.rb, line 10
def self.get_image_size(data)
  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
  [width, height]
end