Urgent.News

What's breaking now, across thousands of outlets.

Tech

png2jxl: Convert PNG to lossless JPEG XL with byte-for-byte reconstruction of the original PNG

png2jxl is a tool that converts supported PNG images into pixel-lossless JPEG XL format. This conversion retains sufficient data to reproduce the original PNG byte-for-byte. The process undergoes automatic encoding and decoding verification against the initial source.

To avoid results larger than the source PNG, the png2jxl extension adds support to the registered JXL save handler. For PNG images backed by a path, the original bytes are retrieved from image.filename. If the image is loaded from a stream or modified in memory, the original bytes must be supplied explicitly using the source_png parameter.

The conversion process maintains the usual JXL/JPEG behavior, continuing to delegate tasks to pillow_jxl. Duplicate palette entries are permissible during the conversion. Public functions accept an immutable ResourceLimits value, with default settings permitting input and output sizes of up to 1 GiB and 512 MiB of filtered plaintext or preflate corrections, respectively.

While some color, transparency, or ancillary-metadata behaviors may be limited by the upstream pillow_jxl encoder, the original PNG bytes remain reconstructable. It's important to note that jxl_to_png currently trusts JXL input, as the upstream decoder fails to provide a dimension-only preflight before pixel allocation. In summary, png2jxl converts PNG to lossless JPEG XL while ensuring a byte-for-byte reconstruction of the original image.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at github.com →

More in Tech

You Wished for It. Here It Is. ❤️

I know how tough it can be to build smooth, secure backend features, so I wanted to bring a little joy to your day and give something back to this amazing community.

More from Thursday 27 August →