Registry / data / pyoxipng

pyoxipng

JSON →
library9.1.1pypypi✓ verified 82d ago

Python wrapper for oxipng, a multithreaded PNG optimizer. Version 9.1.1 supports Python >=3.8 and is actively maintained. Releases follow oxipng upstream closely, typically every few months.

pip install pyoxipng
INSTALL
IMPORT
SIG · PYOXIPNG
P
pyoxipng
datapythonv9.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

optimize
from oxipng import optimize
from pyoxipng import optimize_png
optimize_from_memory
from oxipng import optimize_from_memory
RawImage
from oxipng import RawImage

Read a PNG from file, optimize it in memory, and save the result.

from pyoxipng import optimize_png with open('input.png', 'rb') as f: data = f.read() result = optimize_png(data) with open('output.png', 'wb') as f: f.write(result)
Debug
Known issues
gotchaoptimize_png accepts bytes, not a file path. Passing a file path will fail silently or raise TypeError.
fix
Open the file in binary read mode and pass bytes.
affects: all
breakingVersion 7.0.0 changed the return type from (bytes, bool) to bytes. The second element (whether the image was changed) was removed.
fix
Update code from `result, changed = optimize_png(data)` to `result = optimize_png(data)`. Use `if result != data:` to check if optimized.
affects: >=7.0.0, <8.0.0
deprecatedThe `level` parameter in optimize_png is deprecated since 8.0.0, use `opts` dict instead.
fix
Replace `optimize_png(data, level=6)` with `optimize_png(data, opts=dict(level=6))`.
affects: >=8.0.0
Upgrade
Version history
9.1.1latest on PyPI · released Aug 21, 2025
Audit
Dependencies
pillowoptionalFor loading/saving images when using the Pillow integration
Agent activity
6 hits · last 30 days
node
6
Resources
pyoxipng — pip install pyoxipng · libregistry