Python envelope for the popular C librarylibjpeg for handling JPEG files.
Project description
jpeglib
Python envelope for the popular C library libjpeg for handling JPEG files.
libjpeg offers full control over compression and decompression and exposes DCT coefficients and quantization tables.
Installation
Simply install the package with pip3
pip install jpeglib
:warning: This will install
jpeglib
together with multiple versions of libjpeg, libjpeg-turbo and mozjpeg. For common architectures/OS we provide prebuilt wheels, but installing from source takes couple of minutes.
Usage
Import the library in Python 3
import jpeglib
DCT
Get discrete cosine transform (DCT) coefficients and quantization matrices as numpy array
im = jpeglib.read_dct("input.jpeg")
im.Y; im.Cb; im.Cr; im.qt
You get luminance DCT, chrominance DCT and quantization tables.
Write the DCT coefficients back to a file with
im.write_dct("output.jpeg")
Pixel data
Decompress the input.jpeg
into spatial representation in numpy array with
im = jpeglib.read_spatial("input.jpeg")
im.spatial
You can specify parameters such as output color space, DCT method, dithering, etc.
Write spatial representation in numpy arrray back to file with
im.write_spatial("output.jpeg")
You can specify input color space, DCT method, sampling factor, output quality, smoothing factor etc.
You can find all the details in the documentation.
libjpeg version
It is possible to choose, which version of libjpeg should be used.
jpeglib.version.set('6b')
Currently jpeglib
supports all versions of libjpeg from 6b to 9e, libjpeg-turbo 2.1.0 and mozjpeg 4.0.3.
Their source codes is baked inside the package and thus distributed with it, avoiding external dependency.
Get currently used libjpeg version by
version = jpeglib.version.get()
You can also set a libjpeg version for a scope only.
jpeglib.version.set('6b')
im = jpeglib.read_spatial('image.jpeg') # using 6b
with jpeglib.version('9e'):
im = jpeglib.read_spatial('image.jpeg') # using 9e
im = jpeglib.read_spatial('image.jpeg') # using 6b again
Credits
Developed by Martin Benes, Universität Innsbruck, 2023.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for jpeglib-0.12.7-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 551bc2c61c5dcd9fa971c55445df91c159fd7b65bcf67d51a3ce002353a40330 |
|
MD5 | 4c680f4e0cca5a82d813a0f0f58c8f20 |
|
BLAKE2b-256 | 628c51e53a11c22a6803943405d8d6402c10214564f73aad8819690505a75889 |
Hashes for jpeglib-0.12.7-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5655da1df5c51465b08a83722bdf2978bd2420d36101820163121fc689c27e3c |
|
MD5 | 76f953382419d107489a02fc0d268b0d |
|
BLAKE2b-256 | 1146384e8c9fa7adf8ce08f2adc699ccb9e958b976c00def88ea96ac02fc5950 |
Hashes for jpeglib-0.12.7-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac7866c443f117b5c14f6c6f392e307b7660bb6dd8d02a2aeb754ce0ec38d2d8 |
|
MD5 | 1dc5dba796b1050a0db72d23396624f5 |
|
BLAKE2b-256 | de38e8c58ee11295233b39e014cca9fca3392c6c9684ea6427547f068d6ed7bc |
Hashes for jpeglib-0.12.7-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64651a40b9267d5ee56d54240abc7c778b329cd72a64366d6c97aa443d720b47 |
|
MD5 | 3cf58001929b6e9408a5ae52668d99b3 |
|
BLAKE2b-256 | 3a72220a4421b0734d0515f1f919b9699c38df90812a87f11c977238d9acd640 |
Hashes for jpeglib-0.12.7-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0849129690f093bb5820ddc1d4636417115c1dbce3a6d2169b6aa2cf5ebcecb |
|
MD5 | 06ed7dfe0e9bfa30506d6dfec7b7c2f8 |
|
BLAKE2b-256 | d35d3f228c2e61e2bd1c427e57aabf782f9a217c6b71116298f375d77b64bfa8 |
Hashes for jpeglib-0.12.7-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 469a660054cda7e10faa3d32caf0be8687a34f6c7a8c0a1d13db364bc8fe3a90 |
|
MD5 | 54e39cf8cfa5cba502c74f1fc0246324 |
|
BLAKE2b-256 | 5e95e72e09d2390e1e39e9ecc54a859eba5538ce35916f18d65802e744946f60 |
Hashes for jpeglib-0.12.7-cp38-abi3-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f352806ed28e0d30cf045296f9729f3ff5d168bc3c34dafbcbc54ed10b5818be |
|
MD5 | 9f8335ec0ccc0c9c6820d199db9990de |
|
BLAKE2b-256 | ae1b10395844d08130f296c6d76a2373ec52713bbece55bb681a2e63681e4cef |