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

#246 in Images

Download history 1501/week @ 2024-07-01 1596/week @ 2024-07-08 1433/week @ 2024-07-15 1699/week @ 2024-07-22 1698/week @ 2024-07-29 1553/week @ 2024-08-05 1951/week @ 2024-08-12 1727/week @ 2024-08-19 1948/week @ 2024-08-26 2704/week @ 2024-09-02 2727/week @ 2024-09-09 2012/week @ 2024-09-16 2759/week @ 2024-09-23 2612/week @ 2024-09-30 2584/week @ 2024-10-07 2663/week @ 2024-10-14

10,779 downloads per month
Used in 9 crates (6 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