
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
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.
Simply install the package with pip3
pip install jpeglib
or using the cloned repository
python setup.py install
:warning: This will install
jpeglibtogether 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.
Import the library in Python 3
import jpeglib
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')
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.
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
Developed by Martin Benes, University of Innsbruck, 2023.
FAQs
Python envelope for the popular C library libjpeg for handling JPEG files.
We found that jpeglib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.