Skip to main content

A Python library for reading and writing PNG metadata (tEXt, iTXt, zTXt chunks and XMP)

Project description

pngmeta

A Python library for reading and writing PNG metadata, similar to iptcinfo3 for JPEG files.

Features

  • Read and write PNG text chunks (tEXt, iTXt, zTXt)
  • Handle XMP metadata in PNG files
  • Simple, intuitive API similar to iptcinfo3
  • Pure Python implementation with no dependencies
  • Support for UTF-8 and compressed text chunks

Installation

pip install pngmeta

Or with uv:

uv pip install pngmeta

Quick Start

from pngmeta import PngMeta

# Read metadata
meta = PngMeta('image.png')
print(meta.get('Title'))
print(meta.get('Author'))
print(meta.get('Copyright'))

# Write metadata
meta.set('Title', 'My Image')
meta.set('Author', 'John Doe')
meta.set('Copyright', 'Copyright 2025')
meta.save()

# Save to a new file
meta.save('image_with_metadata.png')

# Work with XMP
xmp = meta.get_xmp()
if xmp:
    print("XMP data:", xmp)

# Dictionary-style access
meta['Description'] = 'A beautiful landscape'
if 'Author' in meta:
    print(f"Author: {meta['Author']}")

# Iterate over all metadata
for key, value in meta.items():
    print(f"{key}: {value}")

Common PNG Text Keywords

  • Title - Short title or caption
  • Author - Image author
  • Description - Longer description
  • Copyright - Copyright notice
  • Creation Time - Original image creation time
  • Software - Software used to create the image
  • Comment - Miscellaneous comment
  • XML:com.adobe.xmp - XMP metadata (automatically handled)

PNG Metadata Background

PNG files store metadata in "ancillary chunks":

  • tEXt - Latin-1 text (uncompressed)
  • iTXt - UTF-8 text (optionally compressed), used for XMP
  • zTXt - Compressed Latin-1 text

Unlike JPEG, PNG doesn't natively use IPTC, but XMP can be embedded in iTXt chunks for cross-format compatibility.

Development

# Clone the repository
git clone https://github.com/yourusername/pngmeta.git
cd pngmeta

# Install with uv
uv venv
source .venv/bin/activate  # or `.venv\Scripts\activate` on Windows
uv pip install -e ".[dev]"

# Run tests
pytest

# Format code
black pngmeta tests

# Type checking
mypy pngmeta

License

This is free and unencumbered software released into the public domain (Unlicense).

See Also

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pngmeta-0.1.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pngmeta-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file pngmeta-0.1.0.tar.gz.

File metadata

  • Download URL: pngmeta-0.1.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.5

File hashes

Hashes for pngmeta-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6539ee3b06ac772a51d86b0037a2c363af3e231601680101e4544e5866e9672c
MD5 df20057f2308cdd52b65afe008291b0f
BLAKE2b-256 d8b200a75caeebf61343729b210cf4e8b5fa47edb0d5ff9c017d948700ab1a8f

See more details on using hashes here.

File details

Details for the file pngmeta-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pngmeta-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.5

File hashes

Hashes for pngmeta-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb2e694362f2fdd6dae3559b9f254e3ccd48363c70a021eb5ea1f8c557631161
MD5 a99a87dba980c4bef1d5541d8e6c5565
BLAKE2b-256 832e68d64c4558db3eeba68cf8219e56dbee6957844a5dc6a7b25508bebacaff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page