Need for Speed: A Comprehensive Benchmark of JPEG Decoders in Python
Vladimir Iglovikov · 2025
Read Need for Speed: A Comprehensive Benchmark of JPEG Decoders in Python by Vladimir Iglovikov (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2501-13131.txt.
Introduction
Vladimir Iglovikov benchmarks Python libraries that decode JPEG images, in work from 2025. Loading images is a bottleneck in machine learning pipelines, and JPEG remains the dominant photo format. The study compares nine popular decoding tools across two computer architectures.
The tools range from classic image libraries and big learning frameworks to specialised fast decoders. Tests ran on an ARM-based high-end chip and on a many-core desktop processor. Modern builds based on an optimised decoding engine ran up to one and a half times faster than traditional options. The author gives evidence-based advice for choosing a decoder by scenario, from high-throughput training to real-time serving. The results can help teams cut training time by fixing an overlooked step.
Catalog record
| CREATOR | Vladimir Iglovikov |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 14 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2501-13131
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Need for Speed: A Comprehensive Benchmark of JPEG Decoders in Python Thanks: https://github.com/ternaus/imread_benchmark Vladimir Iglovikov Abstract Image loading represents a critical bottleneck in modern machine learning pipelines, particularly in computer vision tasks where JPEG remains the dominant format. This study presents a systematic performance analysis of nine popular Python JPEG decoding libraries on different computing architectures. We benchmark traditional image processing libraries (Pillow, OpenCV), machine learning frameworks (TensorFlow, PyTorch), and specialized decoders (jpeg4py, kornia-rs) on both ARM64 (Apple M4 Max) and x86_64 (AMD Threadripper) platforms. Our findings reveal that modern implementations using libjpeg-turbo achieve up to 1.5x faster decoding speeds compared to traditional approaches. We provide evidence-based recommendations for choosing optimal JPEG decoders across different scenarios, from high-throughput training pipelines to real-time applications. This comprehensive analysis helps practitioners make informed decisions about image loading infrastructure, potentially reducing training times and improving system efficiency. 1 Introduction JPEG remains the dominant image format in the digital world [ 1 ] , striking an optimal balance between compression efficiency and image quality. Despite the emergence of newer formats like WebP and AVIF, JPEG’s ubiquity persists across web platforms, digital cameras, and mobile devices. This widespread use makes JPEG decoding performance a critical consideration for many applications. In the Python ecosystem, developers face a choice between multiple libraries capable of JPEG decoding. These range from general-purpose image processing libraries like Pillow and OpenCV [ 2 ] to specialized components of machine learning frameworks such as TensorFlow and PyTorch [ 3 ] . Each library implements JPEG decoding differently, potentially leading to significant performance variations. The speed of JPEG decoding is crucial across numerous real-world applications. In machine learning pipelines, image loading can become a significant bottleneck during training. Web services must efficiently process large volumes of user-uploaded images, while real-time applications require immediate image processing capabilities. Large-scale batch processing systems often handle millions of images, and content delivery networks need to optimize image serving for optimal performance. Despite the importance of JPEG decoding performance, comprehensive and up-to-date benchmarks comparing Python libraries are scarce. Most existing comparisons focus on feature sets rather than performance metrics, quickly become outdated as libraries evolve, lack cross-platform performance analysis, and often miss the impact of underlying JPEG decoder implementations. The complete benchmark implementation and all test results are available as open source at https://github.com/ternaus/imread_benchmark . This study presents a systematic benchmark of popular Python libraries for JPEG decoding across several categories: • Traditional image processing libraries – Pillow and its SIMD-optimized variant (Pillow-SIMD, Linux only) – OpenCV • Scientific computing libraries – scikit-image – imageio • Machine learning framework components – TensorFlow – torchvision – kornia-rs [ 4 ] (Rust implementation) • Specialized JPEG decoders – jpeg4py (direct libjpeg-turbo binding, Linux only) 2 Background and Methodology 2.1 JPEG Decoding Overview JPEG decoding involves several key steps: entropy decoding (Huffman), inverse quantization, and inverse Discrete Cosine Transform (IDCT) [ 1 ] . The performance of these operations can be significantly impacted by the implementation approach and optimizations used . A critical component in JPEG decoding is the underlying decoder library. Most Python libraries rely on either: • libjpeg: The original reference implementation [ 1 ] • libjpeg-turbo: A highly optimized fork that uses SIMD instructions • Custom implementations: Some libraries implement their own decoders or use alternative approaches 2.2 Benchmark Setup Our benchmark measures the end-to-end performance of loading and decoding JPEG images, including disk I/O. This approach reflects real-world usage where both file system operations and decoding affect overall performance. 2.2.1 Test Environment • ARM64: Apple M4 Max (macOS 14.3) • x86_64: AMD Threadripper 3970X (Ubuntu 22.04) 2.2.2 Dataset • 2000 images from ImageNet validation set [ 5 ] • Average file size: 130.2 KB • Resolution range: 90x90 - 3264x2792 pixels 2.2.3 Methodology • 20 runs per library • Cold start for each run (clearing file system cache) • Measuring total time for loading and decoding • Statistical analysis including mean and standard deviation 3 Results Our benchmark reveals significant performance differences between libraries, influenced by their implementation approaches and underlying JPEG decoders. Tests were conducted on two distinct platforms: Apple M4 Max (ARM64) and AMD Threadripper 3970X (x86_64). 3.1 Performance Comparison Figure 1: JPEG Decoding Performance on Apple M4 Max Figure 2: JPEG Decoding Performance on AMD Threadripper 3970X The performance results show interesting patterns across both platforms: 3.1.1 ARM64 Performance (Apple M4 Max) • Top Tier ( > 900 images/sec): – kornia-rs [ 4 ] : Leading performance (1034 img/sec) – OpenCV [ 2 ] : Close second (1016 img/sec) – torchvision [ 3 ] : Strong performance (992 img/sec) • Mid Tier (700-800 images/sec): – imageio: (777 img/sec) – Pillow: (775 img/sec) – scikit-image: (766 img/sec) • Lower Tier : – TensorFlow: (664 img/sec) 3.1.2 x86_64 Performance (AMD Threadripper) • Top Tier : – jpeg4py: Leading on Linux – kornia-rs: Consistent high performance – OpenCV: Strong performance • Mid Tier : – torchvision – Pillow-SIMD (Linux-specific optimization) • Lower Tier : – scikit-image – standard Pillow 3.2 Implementation Impact The performance differences can be attributed to several key factors: 3.2.1 JPEG Decoder Choice Libraries using libjpeg-turbo consistently outperform those using standard libjpeg across both platforms: • Direct libjpeg-turbo users : jpeg4py, kornia-rs [ 4 ] , OpenCV [ 2 ] , torchvision [ 3 ] • Standard libjpeg users [ 1 ] : Pillow, imageio, scikit-image 3.2.2 Implementation Language and Approach The choice of implementation language and approach significantly influences the performance outcomes. Modern implementations, particularly kornia-rs [ 4 ] with its Rust-based approach, show excellent performance across platforms, benefiting from zero-cost abstractions. Direct bindings, as demonstrated by jpeg4py on Linux, achieve similarly strong performance. Among traditional implementations, C/C++ based libraries like OpenCV [ 2 ] maintain consistently high performance, though we observed that multiple abstraction layers tend to impact performance negatively. 3.2.3 Platform-Specific Considerations Our analysis revealed several notable platform-specific patterns. Some libraries, particularly TensorFlow, demonstrate significant performance variations between ARM64 and x86_64 architectures. Platform-specific optimizations, such as Pillow-SIMD on Linux, can provide substantial performance improvements. We observed that modern implementations generally adapt better to newer architectures, and this advantage is particularly evident in testing on the M4 Max platform. 4 Discussion 4.1 Implementation Strategy Impact The choice of implementation strategy significantly affects decoding performance: 4.1.1 Direct Hardware Access • Libraries with direct libjpeg-turbo bindings consistently perform better • Modern implementations (like kornia-rs [ 4 ] ) benefit from reduced overhead • Platform-specific optimizations (SIMD instructions) show measurable impact 4.1.2 Abstraction Cost • Each layer of abstraction introduces performance overhead • High-level APIs (like imageio) trade performance for convenience • Direct bindings (jpeg4py, kornia-rs) minimize this overhead 4.2 Methodology and Implementation Details 4.2.1 Test Configuration • 2000 images from ImageNet [ 5 ] processed in each run • 20 runs per library showed high consistency (low standard deviation) • Fresh virtual environment for each library • No file system caching between runs • Single-threaded execution without batch processing 4.2.2 Library Versions Tested • kornia-rs [ 4 ] : 0.1.8 • OpenCV [ 2 ] : 4.11.0.86 • Pillow : 11.1.0 • Pillow-SIMD: 9.5.0.post2 (Linux only) • imageio: 2.37.0 • scikit-image: 0.25.0 • tensorflow : 2.18.0 (with heavy dependencies) • torchvision [ 3 ] :