Skip to content

PNG: Types

WARNING

  • PNG is pre-v1.0.0, and the public API should be expected to change between releases.
    Not all features defined in the PNG 3.0 specification are currently supported, and certain PNG data may fail or partially fail to decode. (for more information, see PNG: Decoding, Compatibility)

General Types

ColorSpace

luau
"truecolor" | "grayscale" | "indexed"

A string literal specifying the color type of an image.


Chunk

Equivalent to CriticalChunk | AncillaryChunk.

CriticalChunk

luau
| "IHDR" | "PLTE" | "IDAT" | "IEND"

AncillaryChunk

luau
| "tRNS" | "cHRM" | "gAMA" | "iCCP"
| "sBIT" | "sRGB" | "cICP" | "mDCV"
| "cLLI" | "tEXt" | "zTXt" | "iTXt"
| "bKGD" | "pHYs" | "sPLT" | "eXIf"
| "tIME" | "acTL" | "fcTL" | "fdAT"

Decode Types

Parsed

luau
{
	width: number,
	height: number,
	frames: number,
	alpha: boolean,

	headers: {
		interlacing: boolean,
		channels: number,
		bit_depth: number,
		color_space: types.ColorSpace,
	},
	palette: {number}?,

	cel: (frame: number?, target: ColorTarget?) -> (Cel?, CelError),
}
PropertyDescription
headersImage information obtained from the IHDR chunk.
paletteArray of packed RGBA8 colors assigned to palette indexes (1-indexed).
nil if image has no PLTE chunk.
...(see Parsed)

PNG-specific extension of Parsed.


DecodeOptions

luau
{
	crc: ("all" | "critical" | "none")?,
}
PropertyDescription
crcString literal specifying which chunk checksums are validated.

PNG-specific decode options accepted by decode().


DecodeError

Equivalent to Error<DecodeErrorCode>.

DecodeErrorCode

luau
| "unsupported"
| "overflow"
| "unexpected_eof"
| "invalid_signature"
| "invalid_crc"
| "invalid_length"
| "invalid_header"
| "unknown_chunk"
| "missing_chunk"

CelError

Equivalent to Error<CelErrorCode>.

CelErrorCode

luau
| "unsupported"
| "invalid_header"
| "invalid_filter"
| "invalid_option"

Encode Types

(TBD)

Released under the MIT License.