--- id: pyturbojpeg version: "2.5.0" license: MIT license_treatment: permissive maintenance: active --- # PyTurboJPEG — A Python wrapper of libjpeg-turbo for decoding and encoding JPEG image. License: permissive · Maintenance: active · Downloads: 293.0K/mo ## 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 above — 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 pip install pyturbojpeg uv add pyturbojpeg 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_current - Install friction: low - Maintenance: active - Downloads: 293.0K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags fast jpeg encoding decoding, libjpeg-turbo python wrapper, high-performance image compression, jpeg scaling cropping, yuv image processing, turbo jpeg library, batch image conversion, image-compression, numpy-integration [View on SkillFed](https://skillfed.io/packages/pyturbojpeg) · [View on PyPI](https://pypi.org/project/pyturbojpeg/)