Skip to content
YadeWira edited this page Jun 10, 2026 · 5 revisions

packJPG Wiki

packJPG is a lossless JPEG recompressor. It rewrites a .jpg file as a smaller .pjg file that decodes back to the bit-exact original JPEG. Typical reduction: 20–25 %.

Current release: v4.0e (LTS) — adds an embedding library / DLL / .so API (multithreading on by default) and an optional decompression-bomb guard (-maxout / pjglib_set_max_output_size). On-disk .pjg format unchanged — output is byte-exact with v4.0b/c/d.


Quick links

For users

For builders

Background


What does packJPG do?

A JPEG file is a sequence of DCT coefficient blocks Huffman-coded with a fixed table. packJPG reverses the Huffman step, reorganizes the coefficients into per-component / per-position streams, and re-encodes them with a stronger arithmetic coder (PPM order-2 model). The result is byte-exact decompressible back to the original JPEG — same DCT data, same headers, same metadata, same bit-for-bit file.

Use it when you need the original JPEG back later (archival, version control of image-heavy repos, hosted-image "download original" buttons, photo backups). Don't use it for serving images on the web — re-encoding to WebP/JXL/AVIF makes more sense there.


Status

The v4.0 line is the current LTS and is format-stable: every release since v4.0b produces byte-exact .pjg output. v4.0e is the latest update — it adds the embedding library/DLL/.so API and a decompression-bomb guard without changing the on-disk format. Updates within this LTS line stay format-stable (tooling and API additions are fine; anything that would break the .pjg format lands in a future v4.1).

Ratio plateau confirmed empirically — see Comparison with other tools for the numbers vs Brunsli, Lepton, and JXL.


Reporting bugs

Use the Issues tab. Please include:

  • packJPG version (packJPG -v or banner output)
  • OS and architecture
  • A sample .jpg that reproduces the problem (or a description if confidentiality forbids)
  • The exact command line and the full error message

Acknowledgements

Huge thanks to Matthias Stirner (@packjpg) — the original creator of packJPG. This fork stands entirely on the algorithm and codebase he authored and released as open source. See Migration from upstream for the relationship between this fork and his original repository.

And a heartfelt thank-you to the encode.su community — the data-compression forum where most of the feedback, ideas, and stress-testing for this fork comes from. Their questions, benchmarks, and willingness to push back on design choices have shaped every release since v3.0. Special thanks to everyone who has tested builds on uncommon hardware, reported edge cases, suggested format improvements, and kept the conversation around lossless JPEG recompression alive.

Clone this wiki locally