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
10,779 downloads per month
Used in 9 crates
(6 directly)
150KB
3K
SLoC
JPEG encoder
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 thesimd
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 libsimd
: Enables SIMD optimizations (impliesstd
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
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
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.