Skip to content

JPEG encoder written in Rust

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

vstroebel/jpeg-encoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.