Go image/png: the PNG image format
Answer: Package png implements a PNG image decoder and encoder.
Reading an image
Decode reads a PNG image from a reader and returns an image.Image.
DecodeConfig returns an image.Config from a Reader.
Which Image type you get depends on the PNG contents.
Writing an image
Encode writes the Image in PNG format.
The package defines an Encoder type and a CompressionLevel type.
FormatError and UnsupportedError are error types in the package.
See also
Claims
- id: C1 claim: Package png implements a PNG image decoder and encoder. source: S1 evidence: "Package png implements a PNG image decoder and encoder."
- id: C2 claim: Decode reads a PNG image and returns it as an image.Image. source: S1 evidence: "Decode reads a PNG image from r and returns it as an image.Image"
- id: C3 claim: The PNG color type constants follow the PNG spec. source: S2 evidence: "Color type, as per the PNG spec."
- id: C4 claim: The returned Image type depends on the PNG contents. source: S1 evidence: "The type of Image returned depends on the PNG contents."
Sources
- [S1] image/png. The Go Authors. https://pkg.go.dev/image/png . License: BSD-3-Clause. Accessed 2026-11-24.
- [S2] image/png source. The Go Authors. https://go.dev/src/image/png/reader.go . License: BSD-3-Clause. Accessed 2026-11-24.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, image/png; The Go Authors, image/png source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors, image/png; The Go Authors, image/png source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go image/png: the PNG image format." iinventedlight Library, iil:note:06x0mqbt, version of 2026-11-24. https://iinventedlight.com/library/notes/go-png/. License: CC-BY-4.0.
@misc{iil_note_06x0mqbt,
author = {{iinventedlight}},
title = {{Go image/png: the PNG image format}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-24},
url = {https://iinventedlight.com/library/notes/go-png/},
note = {Permanent ID iil:note:06x0mqbt. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- go-png.schema.json (schema; CC-BY-4.0)
- go-png.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-png.md.