Jpeg Reader mojo-native library

Hello everyone!

I wanted to share my open-source project called mojo-image-reader. It is a lightweight and dependency-free JPEG decoder written entirely in the Mojo v1.1.

Purpose: Built as a portfolio showcase and a useful tool for the Mojo ecosystem.

Features:

  • JPEG Support: Baseline (8-bit and 12-bit precision SOF1), Progressive JPEG decoding, and full Chroma Subsampling support (4:4:4, 4:2:2, 4:2:0, and 4:2:0v).

  • Performance & Memory Optimizations: Built with raw pointer arithmetic to bypass bounds-checking.

  • Flexible Export & Interoperability: PPM Exporter (8-bit and 12/16-bit integer color depths), PFM Exporter (32-bit Float HDR), and a NumPy Bridge for zero-copy data exchange.

Project link: https://github.com/AlexALX/mojo-image-reader


Want to know your opinion and does it have any sense to continue and write things listed in the roadmap (BMP, PNG, GIF support)? I would appreciate any feedback or suggestions!

Thanks!

Pushed new updated, so now it supports 1-component jpeg (grayscale), proper restart markers support and optimized with SIMD instructions, made it work in x5 times faster.

Did major updates and finished the roadmap!

The library now supports parsing JPG, PNG, GIF, and BMP, with export capabilities to PPM, PGM, PFM, and PAM formats.

Key highlights:

  • GIF: Frame sequence extraction with proper disposal handling.

  • Precision: Export to 8, 12, or 16-bit files.

  • Performance: Hardware-adaptive SIMD acceleration where applicable + zero-alloc memory optimizations.

Also created a benchmark and sample repository: mojo-image-reader-bench, complete with performance charts comparing it against Python’s Pillow.


Of course, there’s still room to optimize, and I might improve it more later, but the results so far are already very good!