10 releases (6 breaking)

0.6.0 Oct 9, 2023
0.5.1 Mar 31, 2022
0.5.0 Feb 13, 2022
0.4.1 Oct 15, 2021
0.3.0 Jul 29, 2021

#85 in Images

Download history 823/week @ 2023-12-13 789/week @ 2023-12-20 401/week @ 2023-12-27 1123/week @ 2024-01-03 1157/week @ 2024-01-10 1027/week @ 2024-01-17 1015/week @ 2024-01-24 1120/week @ 2024-01-31 1062/week @ 2024-02-07 1068/week @ 2024-02-14 1192/week @ 2024-02-21 1235/week @ 2024-02-28 1221/week @ 2024-03-06 1439/week @ 2024-03-13 1487/week @ 2024-03-20 1053/week @ 2024-03-27

5,489 downloads per month
Used in 6 crates (5 directly)

MIT/Apache

150KB
3K SLoC

JPEG encoder

docs.rs badge crates.io badge Rust

A JPEG encoder written in Rust featuring:

  • Baseline and progressive compression
  • Chroma subsampling
  • Optimized huffman tables
  • 1, 3 and 4 component colorspaces
  • Restart interval
  • Custom quantization tables
  • AVX2 based optimizations (Optional)
  • Support for no_std + alloc
  • No unsafe by default (Enabling the simd feature adds unsafe code)

Example

use jpeg_encoder::{Encoder, ColorType};

// An array with 4 pixels in RGB format.
let data = [
    255, 0, 0,
    0, 255, 0,
    0, 0, 255,
    255, 255, 255,
];

// Create new encoder that writes to a file with maximum quality (100)
let mut encoder = Encoder::new_file("some.jpeg", 100)?;

// Encode the data with dimension 2x2
encoder.encode(&data, 2, 2, ColorType::Rgb)?;

Crate features

  • std (default): Enables functionality dependent on the std lib
  • simd: Enables SIMD optimizations (implies std and only AVX2 as for now)

Minimum Supported Version of Rust (MSRV)

This crate needs at least 1.61 or higher.

License

This project is licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in jpeg-encoder by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps