#jpeg-decoder #codec #jpeg #transform #image #api-bindings

turbojpeg

Fast and easy JPEG encoding, decoding and lossless transforms with TurboJPEG

24 releases (10 stable)

1.3.2 Apr 18, 2025
1.3.0 Mar 10, 2025
1.1.1 Aug 1, 2024
1.1.0 Apr 14, 2024
0.1.0 May 2, 2021

#68 in Images

Download history 1329/week @ 2025-01-11 1413/week @ 2025-01-18 1705/week @ 2025-01-25 1645/week @ 2025-02-01 1450/week @ 2025-02-08 2464/week @ 2025-02-15 3130/week @ 2025-02-22 2794/week @ 2025-03-01 2150/week @ 2025-03-08 2137/week @ 2025-03-15 2286/week @ 2025-03-22 3026/week @ 2025-03-29 3788/week @ 2025-04-05 2802/week @ 2025-04-12 2497/week @ 2025-04-19 2080/week @ 2025-04-26

11,731 downloads per month
Used in 9 crates (8 directly)

Unlicense OR MIT

5MB
93K SLoC

C 56K SLoC // 0.2% comments Assembly 24K SLoC // 0.2% comments GNU Style Assembly 7K SLoC // 0.1% comments Rust 4K SLoC // 0.0% comments JavaScript 1.5K SLoC // 0.1% comments Bitbake 762 SLoC

turbojpeg

Rust bindings for TurboJPEG, which provides simple and fast operations for JPEG images:

  • Compression (encoding)
  • Decompression (decoding)
  • Lossless transformations

Usage with image-rs (version 0.24)

To quickly encode and decode images from the image crate (version 0.24), add this to the [dependencies] section in your Cargo.toml:

turbojpeg = {version = "1.0", features = ["image"]}

and then use the functions turbojpeg::decompress_image and turbojpeg::compress_image.

For more advanced usage without the image crate, please see the documentation.

Requirements

The low-level binding to libturbojpeg is provided by the crate turbojpeg-sys, which needs to link to the C library. Typically, you will need CMake, a C compiler and NASM to build the library from source, but see its README for details.

Contributing

All contributions are welcome! Please contact me (@honzasp) or open a pull request. This crate is rather minimal, the main areas of improvement are:

  • Improving the build process of turbojpeg-sys crate, so that it works seamlessly on a wide range of systems.
  • Testing.
  • Extending the safe Rust API provided by turbojpeg crate.

License

This software is released into the public domain or is available with the MIT license (your choice).

Dependencies