Class: Identify::Image::PNG

Inherits:
Identify::Image show all
Defined in:
lib/identify.rb

Overview

GIF

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Identify::Image

#as_hash, formats, identify, inherited, parse

Class Method Details

.handle?(data) ⇒ Boolean

Returns:

  • (Boolean)


137
138
139
# File 'lib/identify.rb', line 137

def self.handle? data
  data[0..7] == "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A" # png 8-byte signature
end

Instance Method Details

#parse(data) ⇒ Object



141
142
143
144
145
# File 'lib/identify.rb', line 141

def parse data
  {}.tap do |meta|
    meta.merge! as_hash('png', *data.unpack("x16NN")) if data[12..15] == "IHDR"
  end
end