#jpeg #image #transform #decoder #encoder #codec

turbojpeg

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

18 releases (4 stable)

1.1.0 Apr 14, 2024
1.0.1 Mar 17, 2024
0.5.4 Jul 31, 2023
0.5.2 Sep 23, 2022
0.1.0 May 2, 2021

#73 in Images

Download history 471/week @ 2024-01-03 473/week @ 2024-01-10 555/week @ 2024-01-17 898/week @ 2024-01-24 594/week @ 2024-01-31 706/week @ 2024-02-07 887/week @ 2024-02-14 790/week @ 2024-02-21 1063/week @ 2024-02-28 1046/week @ 2024-03-06 1740/week @ 2024-03-13 1150/week @ 2024-03-20 946/week @ 2024-03-27 1329/week @ 2024-04-03 1337/week @ 2024-04-10 947/week @ 2024-04-17

4,708 downloads per month
Used in 5 crates

Unlicense OR MIT

4.5MB
87K SLoC

C 52K SLoC // 0.2% comments Assembly 24K SLoC // 0.2% comments GNU Style Assembly 7K SLoC // 0.1% comments Rust 3.5K SLoC // 0.0% comments Bitbake 742 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

~0.3–3MB
~27K SLoC