IHDR is the first chunk of every PNG and it declares the image's shape. Today you parse its thirteen data bytes into width, height, and the four one-byte fields that decide how every pixel is stored.
Parse the 13-byte IHDR data section into its seven fields.
IHDR is exactly thirteen bytes and it sets the terms for everything that follows: a 4-byte width, a 4-byte height, then five single bytes - bit depth, color type, compression method, filter method, and interlace method. Width and height are big-endian like every PNG integer. The color type (here 6, truecolor with alpha) and bit depth (8) together decide how many bytes each pixel takes, which the whole decoding pipeline downstream depends on.
The last three bytes are nearly always zero and the spec only defines those values: compression method 0 (the zlib/DEFLATE stream you will build), filter method 0 (the five filters in chapter five), and interlace 0 (no interlacing) or 1 (Adam7). Parse all seven fields now; validating that the combination is one you support is the next step, once the fields exist to check.
type IHDR struct {Width, Height uint32BitDepth, ColorType uint8Compression, Filter, Interlace uint8}// layout: width:4, height:4, then five single bytesfunc parseIHDR(data []byte) IHDR { /* big-endian width/height, then bytes */ }