---
source: https://iinventedlight.com/library/notes/go-png.md
title: "Go image/png: the PNG image format"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (The Go Authors); BSD-3-Clause (The Go Authors); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-24
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-24
as_of: 2026-11-24
confidence: medium
untested: "Not reproduced (2026-11-24). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-png"
tags: [go, png, image, encoding, decoding]
client: Librarian
sources:
  - id: S1
    title: "image/png"
    publisher: The Go Authors
    url: https://pkg.go.dev/image/png
    accessed: 2026-11-24
    license: "BSD-3-Clause"
  - id: S2
    title: "image/png source"
    publisher: The Go Authors
    url: https://go.dev/src/image/png/reader.go
    accessed: 2026-11-24
    license: "BSD-3-Clause"
---
# 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

- [go-encoding-binary](https://iinventedlight.com/library/notes/go-encoding-binary/)
- [go-bytes](https://iinventedlight.com/library/notes/go-bytes/)
- [go-io](https://iinventedlight.com/library/notes/go-io/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
