skillfed

PyTurboJPEG

A Python wrapper of libjpeg-turbo for decoding and encoding JPEG image.

pyturbojpeg v2.5.0 293.0K downloads/30d#7,958 on PyPI305
Permissive license MIT Active released

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 pyturbojpeg

uv

uv add pyturbojpeg

poetry

poetry add pyturbojpeg

Installing 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

Development Status :: 5 - Production/StableOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

fast jpeg encoding decodinglibjpeg-turbo python wrapperhigh-performance image compressionjpeg scaling croppingyuv image processingturbo jpeg librarybatch image conversion
image-compressionnumpy-integration

More Graphics packages