Registry / serialization / pyjpegls

pyjpegls

JSON →
library1.5.1pypypi✓ verified 82d ago

Python wrapper for the CharLS C++ library, providing JPEG-LS lossless and near-lossless image compression. Current version 1.5.1, requires Python >=3.9. Active development with occasional releases.

pip install pyjpegls
INSTALL
IMPORT
SIG · PYJPEGLS
P
pyjpegls
serializationpythonv1.5.1
Install
3.8s avg
Import
Disk
95MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.5.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.8s · import 0.000s · 93MB
95MB installed
● package 95MB
Code
Verified usage

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

encode
from jpeg_ls import encode
from pyjpegls import encode
decode
from jpeg_ls import decode
from pyjpegls import decode
CharLS
from jpeg_ls import CharLS
from pyjpegls import CharLS

Encode and decode a grayscale image with default lossless settings.

import numpy as np from pyjpegls import encode, decode, ImageFormat, InterleaveMode # Create a sample 8-bit grayscale image (height, width) image = np.random.randint(0, 256, size=(256, 256), dtype=np.uint8) # Encode (lossless by default) encoded = encode(image, interleave_mode=InterleaveMode.NONE) print(f"Encoded size: {len(encoded)} bytes") # Decode back decoded = decode(encoded) print(f"Decoded shape: {decoded.shape}, dtype: {decoded.dtype}") # Verify lossless reconstruction assert np.array_equal(image, decoded), "Lossless check failed"
Debug
Known issues
gotchaThe library expects numpy arrays in (height, width) order, not (width, height). Misordered dimensions can cause silent incorrect encoding or runtime errors.
fix
Ensure your numpy array shape is (height, width, channels) for color or (height, width) for grayscale.
affects: all
gotchaSupported input dtypes are uint8, int16, and uint16 only (including signed/unsigned). Using other dtypes (e.g., float32) will raise a ValueError.
fix
Cast your array to one of the supported types before encoding: image.astype(np.uint8) or np.int16 or np.uint16.
affects: all
gotchaFor color (multi-plane) images, the array should be in (height, width, planes) order and must use InterleaveMode.SAMPLE (pixel interleaved) or InterleaveMode.LINE (line interleaved). InterleaveMode.NONE is for single-plane grayscale only.
fix
For RGB images: ensure shape is (H, W, 3) and use InterleaveMode.SAMPLE.
affects: all
gotchaThe decode function returns a numpy array; it does not return a PIL Image or any other object. Converting to PIL requires explicit conversion.
fix
Use Image.fromarray(decoded) if you need a PIL Image (after appropriate mode/format conversion).
affects: all
Upgrade
Version history
1.5.1latest on PyPI · released Oct 28, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
10
Resources
pyjpegls — pip install pyjpegls · libregistry