Library / embedding release for the v4.0 LTS line. On-disk .pjg format is unchanged from v4.0b/c/d — output is byte-exact, full backward compatibility: v4.0e decodes every v4.0-line file (v4.0, v4.0a, v4.0b, v4.0c, v4.0d). Not a format break, no v4.1.
What's new
-
Embedding library API — a C-linkage API to use packJPG inside other programs (archivers, image tools, web services). Available as a self-contained Windows DLL (
packJPG.dll, no external runtime DLLs), a Unix shared object (libpackJPG.so), and a static lib (packJPGlib.a). Same.pjgformat as the CLI. -
Multithreading on by default in the library: each single-file convert uses up to 3 cores (Y/Cb/Cr) when the host has ≥3 logical cores. New
pjglib_convert_batch()converts N files in parallel over a worker pool, plus thread controls (pjglib_set_intra/inter_file_threads,pjglib_suggest_batch_threads). No code change required in existing FFI consumers. -
Decompression-bomb guard — a malformed
.pjgcan reconstruct into a much larger JPEG (a tiny low-entropy trailing blob expands on decode; this is inherent to lossless compression and is present in upstream packJPG too). New optional cap makes the decoder fail cleanly instead of producing oversized output, for hosts decoding untrusted.pjg:- CLI:
-maxout<MB>(e.g.packjpg x -maxout64 file.pjg). - Library:
pjglib_set_max_output_size(bytes). - Default off (
0= unlimited) — no behavior change for trusted workflows.
- CLI:
-
Bug fixes (found in a QA pass over a 153-file real-world JPEG corpus + ASan/UBSan/TSan):
- Windows DLL crashed at process exit after the first convert under the MinGW win32 thread model — now built with the posix model (the
dlltarget refuses the broken model). pjglib_convert_batchfile→file without_dest=NULLwrote the wrong extension on decompress, clobbering the source.pjg— now picks the extension from the input's magic.- Per-worker-thread memory leak of the filename buffers.
- Windows DLL crashed at process exit after the first convert under the MinGW win32 thread model — now built with the posix model (the
-
Legacy build (XP/Vista/7/8) bumped to v4.0e with the same decompression guard (
-maxout<MB>). The library MT API issource/-only (it relies onthread_local, which the XP toolchain lacks).
Compatibility
.pjg from |
Decoded by v4.0e |
|---|---|
| v4.0 / v4.0a | ✅ (transparent) |
| v4.0b / v4.0c / v4.0d | ✅ (byte-exact) |
| v3.x / v2.x | ❌ — use the v3.1d build |
Verified on Linux, Windows 10 (x64), and Windows 7 (x64 + x86): round-trip byte-exact; library round-trip byte-exact across the inter×intra thread grid; guard aborts oversized decodes cleanly.
Embedding
See the README › Library / DLL API for the function reference and a worked example. Ready-to-link SDK archives are attached — each contains the library, headers, and (Windows) an MSVC .def:
| Asset | Contents |
|---|---|
packJPG-4.0e-win64-lib.zip |
packJPG.dll (x64, self-contained) + libpackJPG.a + packJPG.def + headers |
packJPG-4.0e-win32-lib.zip |
same, 32-bit (XP+) |
packJPG-4.0e-linux-x64-lib.tar.gz |
libpackJPG.so + packJPGlib.a (static) + header |