Generic PNG chunk structure.
Each PNG chunk consists of a 4-byte length field, 4-byte type field, variable-length data, and 4-byte CRC checksum. The length field specifies the number of bytes in the data field.
Creating a PNG chunk
Creating a PNG chunk
import { assertEquals } from "@std/assert"; import type { PngChunkUnknown } from "@binstruct/png"; const chunk: PngChunkUnknown = { length: 13, type: new Uint8Array([73, 72, 68, 82]), // "IHDR" data: new Uint8Array([0, 0, 0, 1, 0, 0, 0, 1, 8, 2, 0, 0, 0]), crc: 0x12345678, }; assertEquals(chunk.length, chunk.data.length); assertEquals(chunk.type.length, 4);