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 every integrated version of libjpeg, libjpeg-turbo and mozjpeg. It takes longer to install than the package.
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.
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.11.6-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01a20b303c1ab7d184a983e5183db3a0562c11919f46ac45f00a4b3764761d65 |
|
MD5 | 8145372873236fbe5adef6a4c2bf41b3 |
|
BLAKE2b-256 | 446861e393df1dd18b6b136b933646d9f2eb2030da99c6f41b4819b73dfba136 |
Hashes for jpeglib-0.11.6-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 725747f6299026d46c566da6290e53a5dbad107f9a0c602a2ec6ae627e1999d5 |
|
MD5 | fd8141c1a8ab2baf4a6e304eee4b3043 |
|
BLAKE2b-256 | 2ffcee445f1ca9a576b9ed06f509e99eca0eb7345fab15739dfb22c488c8d416 |
Hashes for jpeglib-0.11.6-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 226d80c042120f50df0e1219dcb000b7cc9b60ebb7fe24106f0ababf9c12e2fe |
|
MD5 | 8987bcc443e7a21dcd1d1926c6e60d24 |
|
BLAKE2b-256 | 8c76ede3b13decf05ed51197398d4d9612aa4167f11a2e60a12c77d031bc22af |
Hashes for jpeglib-0.11.6-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 441ac0edc299e5cc18fe3a7e76e66e4b19eacecbea927c5673cb92e4f9679053 |
|
MD5 | 7d94da26c76bd3179f4587f3b59c7af2 |
|
BLAKE2b-256 | 5ba802d3a1d0de60f7816a038cec6f0f0e7ca5984c2f0fc14bc719f6d4e34bd3 |
Hashes for jpeglib-0.11.6-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a91dd1234a88db4a489927e7c6c1e268cf70b575b102532f5f403db02c16729 |
|
MD5 | df22735a117e24ff65f520f83a5a22d3 |
|
BLAKE2b-256 | 22660104ff33f560a7250d6c3dbfe4117f6123f23a82b1096155ab2f2088ff27 |
Hashes for jpeglib-0.11.6-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e2c63e8573e9fef3eb37af3877dfc9c844b2414524565a02868424a0ce55e70 |
|
MD5 | a8de15ca6a2a196489dc81adc00c69f6 |
|
BLAKE2b-256 | 3b6c763b89d350221c10d5aedfc1c38c3af96d0575a2d08cdbc0bba0212ddedc |
Hashes for jpeglib-0.11.6-cp38-abi3-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10c0381ba93e22b33472dfcfeebd00649c63c9306d4f370fe7bf2d03d90743a9 |
|
MD5 | 1bc6ea7e37e6307077aa6e3b73b25f1b |
|
BLAKE2b-256 | 4de8c4c5a34cdeba90e285d0d28716cd25e511ce8b4c77902429691c8a8affcd |