images-compressor

Crates.ioimages-compressor
lib.rsimages-compressor
version1.0.3
sourcesrc
created_at2024-01-02 05:27:12.559425
updated_at2024-03-26 07:49:33.781842
descriptioncompress pictures, such as `png`、`jpg`、`jpeg`、`git`.
homepagehttps://github.com/poohlaha/rust-tools/tree/main/packages/images
repositoryhttps://github.com/poohlaha/rust-tools/tree/main/packages/images
max_upload_size
id1085810
size41,301
Kauren J (poohlaha)

documentation

README

images-compressor

compress pictures, such as pngjpgjpeggit

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)

Commit count: 0

cargo fmt