png

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package png implements extraction and injection of EXIF and XMP metadata within PNG files.

PNG structure: 8-byte signature followed by chunks, each with: 4-byte length + 4-byte type + <length> bytes data + 4-byte CRC.

Relevant chunks:

  • eXIf (PNG Extension, registered 2017): raw EXIF payload.
  • iTXt with keyword "XML:com.adobe.xmp": XMP packet (RFC 2083 §12.13).

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSignature = errors.New("png: invalid signature")

ErrInvalidSignature is returned when the input does not begin with the PNG magic bytes.

View Source
var ErrUnsupportedCompression = errors.New("png: unsupported compression method")

ErrUnsupportedCompression is returned when a compressed chunk uses an unknown compression method.

Functions

func Extract

func Extract(r io.ReadSeeker) (rawEXIF, rawIPTC, rawXMP []byte, err error)

Extract reads the PNG chunk stream from r and returns raw metadata payloads.

func Inject

func Inject(r io.ReadSeeker, w io.Writer, rawEXIF, rawIPTC, rawXMP []byte) error

Inject reads the PNG chunk stream from r, replaces or inserts the eXIf and iTXt(XMP) chunks, and writes the result to w. IPTC is not natively supported in PNG; rawIPTC is ignored.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL