class ChunkyPNG::Chunk::Header

@see www.w3.org/TR/PNG/#11IHDR<br><br>ChunkyPNG will raise an exception if you try to access the pixel data.
Note that it is still possible to access the chunk for such an image, but
PNG spec, except for color depth: Only 8-bit depth images are supported.
ChunkyPNG supports all values for these variables that are defined in the
method.
depth, color mode, compression method, filtering method and interlace
contains information about the image: i.e. its width, height, color
The header (IHDR) chunk is the first chunk of every PNG image, and

def self.read(type, content)

Returns:
  • (ChunkyPNG::Chunk::End) - The new Header chunk instance with the

Parameters:
  • content (String) -- The 13 bytes of content read from the chunk.
  • type (String) -- The four character chunk type indicator (= "IHDR").
def self.read(type, content)
  fields = content.unpack("NNC5")
  new(
    width: fields[0],
    height: fields[1],
    depth: fields[2],
    color: fields[3],
    compression: fields[4],
    filtering: fields[5],
    interlace: fields[6]
  )
end

def content

Returns:
  • (String) - The 13-byte content for the header chunk.
def content
  [
    width,
    height,
    depth,
    color,
    compression,
    filtering,
    interlace,
  ].pack("NNC5")
end

def initialize(attrs = {})

def initialize(attrs = {})
  super("IHDR", attrs)
  @depth       ||= 8
  @color       ||= ChunkyPNG::COLOR_TRUECOLOR
  @compression ||= ChunkyPNG::COMPRESSION_DEFAULT
  @filtering   ||= ChunkyPNG::FILTERING_DEFAULT
  @interlace   ||= ChunkyPNG::INTERLACING_NONE
end