Crates.io | images-compressor |
lib.rs | images-compressor |
version | 1.0.3 |
source | src |
created_at | 2024-01-02 05:27:12.559425 |
updated_at | 2024-03-26 07:49:33.781842 |
description | compress pictures, such as `png`、`jpg`、`jpeg`、`git`. |
homepage | https://github.com/poohlaha/rust-tools/tree/main/packages/images |
repository | https://github.com/poohlaha/rust-tools/tree/main/packages/images |
max_upload_size | |
id | 1085810 |
size | 41,301 |
compress pictures, such as png
、jpg
、jpeg
、git
。
To use images-compressor
, first add this to your Cargo.toml
:
[dependencies]
images-compressor = "1.0"
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();
}
Apache License, Version 2.0 (LICENSE or https://apache.org/licenses/LICENSE-2.0)