4 stable releases
1.0.3 | Mar 26, 2024 |
---|---|
1.0.1 | Jan 2, 2024 |
#811 in Images
118 downloads per month
30KB
577 lines
images-compressor
compress pictures, such as png
、jpg
、jpeg
、git
。
Usage
To use images-compressor
, first add this to your Cargo.toml
:
[dependencies]
images-compressor = "1.0"
Examples
use images_compressor::compressor::{Compressor, CompressorArgs};
use images_compressor::factor::Factor;
fn main() {
let factor = Factor{
quality: 80.0, // 品质: 0 - 100
size_ratio: 0.8, // // 压缩比例: 0 - 1
};
let args = CompressorArgs {
factor: Some(factor),
origin: "/usr/local/images/outputs".to_string(),
dest: "/usr/local/images/outputs".to_string(),
thread_count: None,
image_size: 0,
};
let compressor = Compressor::new(args);
compressor.compress().ok();
}
License
Apache License, Version 2.0 (LICENSE or https://apache.org/licenses/LICENSE-2.0)
Dependencies
~10–20MB
~211K SLoC