png2jxl
png2jxl converts supported PNG images to pixel-lossless JPEG XL while preserving enough information to reconstruct the original PNG byte-for-byte.
Installation
pip install -U png2jxl
Python API
from png2jxl import jxl_to_png, png_to_jxl
source = open("image.png", "rb").read()
archive = png_to_jxl(source)
assert archive is not None
assert jxl_to_png(archive) == source
Encoding and decoding are verified automatically against the original source.
To reject results that are larger than the source PNG:
archive = png_to_jxl(source, effort=10, only_if_smaller=True)
Command line
python -m png2jxl encode image.png # writes image.jxl
python -m png2jxl decode image.jxl # writes image.png
python -m png2jxl check image.jxl # checks for the pngr envelope
- Use
-o/--outputto choose an output path; otherwise the extension is swapped automatically. - Existing output files are never overwritten.
encodesupports--effort 1-10,--threads, and--only-if-smaller.- Exit codes:
0success,1failure,2usage error,3rejected by--only-if-smaller.
Pillow integration
Importing png2jxl extends the registered JXL save handler:
import png2jxl
from PIL import Image
with Image.open("image.png") as image:
image.save(
"image.png.jxl",
format="JXL",
png_reconstruction=True,
effort=10,
)
For path-backed PNG images, the original bytes are read from image.filename. For images opened from streams or modified in memory, pass the original bytes explicitly with source_png=source.
Ordinary JXL/JPEG behavior continues to delegate to pillow_jxl.
Supported PNGs
Supported:
- Static 8-bit
L,LA,RGB, andRGBAimages - 8-bit indexed-color PNGs with a valid
PLTEand optionaltRNS - PNG filters 0–4
- Consecutive
IDATchunks
Not supported:
- 1/2/4-bit indexed samples
- 16-bit samples
- APNG
- Indexed images where two used palette entries resolve to the same effective RGBA color
Unused duplicate palette entries are allowed.
Limits and notes
Public functions accept an immutable ResourceLimits value. Defaults allow up to 1 GiB input/output and 512 MiB of filtered plaintext or preflate corrections.
Some generic-viewer color, transparency, or ancillary-metadata behavior may be limited by the upstream pillow_jxl encoder even though the original PNG bytes remain reconstructable. jxl_to_png currently assumes trusted JXL input because the upstream decoder does not expose a dimension-only preflight before pixel allocation.
Dependencies
pillow-jxl-plugin— JPEG XL encoding and decodingpreflate-rs— exact reconstruction of the original DEFLATE stream
Development
Metadata
Release files for png2jxl 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| png2jxl-0.2.0.tar.gz | 59.4 kB | Details |
Built distributions (wheels)
Total release size: 4.0 MB
Release files / png2jxl-0.2.0.tar.gz
| Download URL | png2jxl-0.2.0.tar.gz |
|---|---|
| Size | 59.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ab7fbcafe5c04a55ad1da29bf35ee0892f7a4828dd43f88b6ed162aaa56a2bf
|
|
BLAKE2b-256 checksum How to use checksums |
137dcc76747f5237c7d399a3a6d55d89c36587cfb6ac53c04aae91164ef0ca0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / png2jxl-0.2.0-cp314-abi3-win_amd64.whl
| Download URL | png2jxl-0.2.0-cp314-abi3-win_amd64.whl |
|---|---|
| Size | 271.0 kB |
| Tags | CPython 3.14 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
07adbd370c6f76022e5633d2281fecbec18fccdd4aeaabd43243e740379b2bb2
|
|
BLAKE2b-256 checksum How to use checksums |
9e690da25c8bf2d94977feeab21e271fc666acbeb5a9d2dfb765163ba867e353
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / png2jxl-0.2.0-cp314-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | png2jxl-0.2.0-cp314-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 370.2 kB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
effcf5fdafba9219313279a4fb32bf211c33e091af12d0ae8cab01e1df36f945
|
|
BLAKE2b-256 checksum How to use checksums |
79df9ad51ce931442fc4674e3992a0f49cd24228ec43b50a833cfefe546b8c9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / png2jxl-0.2.0-cp314-abi3-macosx_11_0_arm64.whl
| Download URL | png2jxl-0.2.0-cp314-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 336.0 kB |
| Tags | CPython 3.14 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
379f66138aeba0586e9b2fb0de66523ce3262feefc306985a37484b6aadb08ab
|
|
BLAKE2b-256 checksum How to use checksums |
c387e63863476e4a61f52c782d92a18a1bd3dbf8809ba6b0ecf0ace4d5210c8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / png2jxl-0.2.0-cp313-cp313-win_amd64.whl
| Download URL | png2jxl-0.2.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 270.4 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6f1f169d659cd0e64e88591eb910eae6ebaf0325c956d8d4a53045d83ef2d302
|
|
BLAKE2b-256 checksum How to use checksums |
eaee263d6f8c46491fafad1fc39a338d8ddac370fc3e20e10376e96d9d5237c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / png2jxl-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | png2jxl-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 371.5 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
6bf520e350b3dd423ad313ce9101703bc4b35b488111c21c033a93488bb7b6da
|
|
BLAKE2b-256 checksum How to use checksums |
fc6bd3f7993a16627e8c70e02f040fe569f3e7e573edb80ac2758e0558b97eaa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / png2jxl-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | png2jxl-0.2.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 336.6 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e53b13bcbf78ad05623b834d483aa5f41390bf5165dd1129dc4042a81cd641ea
|
|
BLAKE2b-256 checksum How to use checksums |
67aad8b01d1e2feb6718469d5a515176d853651d047bc5131a15b5687728e082
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / png2jxl-0.2.0-cp312-cp312-win_amd64.whl
| Download URL | png2jxl-0.2.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 270.8 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0ab4a51aaa1bf9973a330e4a3926dfad9d8aabbc4d64a6d9d45ff54e306c3024
|
|
BLAKE2b-256 checksum How to use checksums |
813579a48be75df8757b44a4f73d534f0059095a68aa65b48dbfa1fff62aa02e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / png2jxl-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | png2jxl-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 371.8 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
77d4cb338cf4fa155fab77655704ba5ad58a9d0a2367280cd4e5e2141df7014b
|
|
BLAKE2b-256 checksum How to use checksums |
ce897d3bf4827be5323076ca37f0a71c446d4cc9c28e0ea86af73d9c6b3856f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / png2jxl-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | png2jxl-0.2.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 336.8 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
de314c79eb8da41eeb9db01837e208fcfe75576f90da4f067d0b6ced495cb7cc
|
|
BLAKE2b-256 checksum How to use checksums |
01560e1077b1ff81d049895d856e08ef0a684f109707d9a8bc2b04d75135c110
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / png2jxl-0.2.0-cp311-cp311-win_amd64.whl
| Download URL | png2jxl-0.2.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 273.1 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
17119a9ddddb17aee602b9258d20d1027d5d267abf1c9e511eb5a5f54d36fac3
|
|
BLAKE2b-256 checksum How to use checksums |
cef117eb2a33d69b77d4d8246361128e7dd7729690797f1e8407df4a7914ea6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / png2jxl-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | png2jxl-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 372.2 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
7f8e80da2c970f67a1d7f632ee0a033057118fa67f12c6ea229564643014d3c9
|
|
BLAKE2b-256 checksum How to use checksums |
58de3a3c593e3b51de93bd79d486853fb260b285f32a0674ddf43704da497be7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / png2jxl-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | png2jxl-0.2.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 339.0 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2cb2b3920a20a118d64c085531d8b2f4b7889e5631ccb5a0dfbf7b9b524abafe
|
|
BLAKE2b-256 checksum How to use checksums |
512e1b6a374dc645e9f320167361095b65c1f45f7e2294a950c0905d4a995c10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency log