PyTurboJPEG
A Python wrapper of libjpeg-turbo for decoding and encoding JPEG image.
What it is and what it does
PyTurboJPEG is a Python binding to libjpeg-turbo that lets you decode JPEG files into numpy arrays and re-encode them with control over quality, color format, and subsampling. The package supports advanced operations like lossless cropping, scaling with quality preservation, YUV planar decoding, and in-place operations to reuse memory buffers. It handles multiple JPEG precisions and can extract header information without full decompression.
The main constraint is that libjpeg-turbo 3.0 or later must be installed separately as a system library. Once that is in place, the package integrates with numpy and works across Python 3.8 through 3.14. Resource limits are disabled by default to support large-image workflows, but can be configured when processing untrusted JPEGs. The API exposes both high-level convenience methods and lower-level control through flags and parameters.
Use it for:
- Batch convert or re-encode large JPEG collections with custom quality settings or subsampling to reduce file size.
- Decode JPEG images directly into numpy arrays for computer vision pipelines without intermediate format conversions.
- Extract JPEG header metadata (dimensions, subsampling, colorspace) before deciding whether to decode the full image.
- Perform lossless JPEG operations like cropping or Huffman table optimization without re-encoding pixel data.
- Decode JPEG to YUV planes for video processing or direct GPU upload without RGB conversion overhead.
- Scale JPEG images on-the-fly during decode to reduce memory usage in memory-constrained environments.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyTurboJPEG wraps libjpeg-turbo to decode and encode JPEG images efficiently, supporting multiple color formats, scaling, and lossless operations on numpy arrays.
Yes. PyTurboJPEG is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and offers genuine performance benefits for JPEG-heavy workflows through libjpeg-turbo's optimized codec. The main requirement—installing libjpeg-turbo 3.0 or later as a system library—is a one-time setup cost. Install it if you need fast JPEG encoding and decoding, especially in batch or real-time image processing pipelines.
Install
pyturbojpeg on PyPI
pip
pip install pyturbojpeguv
uv add pyturbojpegpoetry
poetry add pyturbojpegInstalling PyTurboJPEG
Before you install
Low install friction with a pure-wheel distribution, but requires libjpeg-turbo 3.0 or later as a system library—not a Python dependency. The package is actively maintained with a recent release and no known vulnerabilities.
License in practice
MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute PyTurboJPEG freely provided you include the license notice.
Quickstart
pip install pyturbojpeg
import numpy
from pyturbojpeg import TurboJPEG
jpeg = TurboJPEG()
with open('input.jpg', 'rb') as f:
bgr_array = jpeg.decode(f.read())
with open('output.jpg', 'wb') as f:
f.write(jpeg.encode(bgr_array))
libjpeg-turbo 3.0 or later must be installed as a system library before importing PyTurboJPEG; on macOS use `brew install jpeg-turbo`, on Linux/Windows download from the official libjpeg-turbo releases.
Verify before relying
- Whether the package's resource limits (max_pixels, max_memory, scan_limit) are suitable for your typical image sizes and untrusted input scenarios.
- Performance gains over standard libjpeg or other JPEG libraries in your specific use case.
- Compatibility with libjpeg-turbo versions prior to 3.0 (PyTurboJPEG 1.x may be required).
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | actively maintained — 31 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 293,025/month — #7,958 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyturbojpeg-2.5.0-py3-none-any.whl
Tags
More Graphics packages
Pillow adds image processing capabilities to…
permissive · top 100 on PyPI
fonttoolsfonttools manipulates font files in multiple…
permissive · top 1,000 on PyPI
matplotlib-inlineEnables matplotlib figures to display inline…
permissive · top 1,000 on PyPI
pymupdfPyMuPDF extracts, renders, converts, and…
agpl · top 1,000 on PyPI
pypdfium2pypdfium2 is a Python binding to PDFium that…
permissive · top 1,000 on PyPI
altairAltair is a declarative Python library for…
permissive · top 1,000 on PyPI
simplejpegEncodes and decodes JPEG images directly to and…
permissive · top 15,000 on PyPI
turbojpegPython bindings for libjpeg-turbo that provide…
unclear · top 15,000 on PyPI
pillow-jxl-pluginRegisters JPEG-XL codec support with Pillow,…
unclear · top 15,000 on PyPI
pylibjpeg-libjpegDecodes JPEG and JPEG-LS images to NumPy…
copyleft · top 15,000 on PyPI
pylibjpegDecodes and encodes JPEG, JPEG-LS, JPEG 2000,…
permissive · top 15,000 on PyPI
pyjpeglsEncodes and decodes image data using the…
permissive · top 15,000 on PyPI
qoiA Python wrapper for the QOI (Quite OK Image)…
permissive · top 15,000 on PyPI
pylibjpeg-openjpegDecodes and encodes JPEG 2000 images to and…
permissive · top 15,000 on PyPI
edk2-pytool-libraryProvides Python classes and utilities for UEFI…
unclear · top 15,000 on PyPI
img2pdfConverts raster images to PDF without…
copyleft · top 5,000 on PyPI