zopfli option
This commit is contained in:
parent
d670d5303e
commit
4395e2c41a
|
@ -89,11 +89,11 @@ checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
|
|||
|
||||
[[package]]
|
||||
name = "caesiumclt"
|
||||
version = "0.19.0"
|
||||
version = "0.19.1"
|
||||
dependencies = [
|
||||
"human_bytes",
|
||||
"indicatif",
|
||||
"infer 0.11.0",
|
||||
"infer 0.12.0",
|
||||
"libcaesium",
|
||||
"num_cpus",
|
||||
"rand",
|
||||
|
@ -479,9 +479,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "infer"
|
||||
version = "0.11.0"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a6c16b11a665b26aeeb9b1d7f954cdeb034be38dd00adab4f2ae921a8fee804"
|
||||
checksum = "a898e4b7951673fce96614ce5751d13c40fc5674bc2d759288e46c3ab62598b3"
|
||||
dependencies = [
|
||||
"cfb",
|
||||
]
|
||||
|
@ -531,7 +531,7 @@ checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
|
|||
[[package]]
|
||||
name = "libcaesium"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/Lymphatus/libcaesium?rev=eca05e2#eca05e2eb8870c873118a9e43c2e9b60f83b12b8"
|
||||
source = "git+https://github.com/Lymphatus/libcaesium?tag=0.10.1#a71a855b9eb76451f46cfb0d171da0a39c07829e"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"gifsicle",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "caesiumclt"
|
||||
version = "0.19.0"
|
||||
version = "0.19.1"
|
||||
authors = ["Matteo Paonessa <matteo.paonessa@gmail.com>"]
|
||||
edition = "2021"
|
||||
|
||||
|
@ -10,8 +10,8 @@ structopt = "0.3"
|
|||
indicatif = "0.17"
|
||||
walkdir = "2.3"
|
||||
num_cpus = "1.13"
|
||||
infer = "0.11"
|
||||
infer = "0.12.0"
|
||||
rayon = "1.5"
|
||||
rand = "0.8"
|
||||
human_bytes = { version = "0.4", default-features = false }
|
||||
libcaesium = { git = "https://github.com/Lymphatus/libcaesium", rev = "eca05e2" }
|
||||
libcaesium = { git = "https://github.com/Lymphatus/libcaesium", tag = "0.10.1" }
|
|
@ -1,5 +1,6 @@
|
|||
pub enum ErrorLevel {
|
||||
Log,
|
||||
Notice,
|
||||
Warning,
|
||||
Error,
|
||||
}
|
||||
|
@ -11,6 +12,7 @@ pub fn log(message: &str, code: i32, level: ErrorLevel, verbose: u8) {
|
|||
match level {
|
||||
ErrorLevel::Error => panic!("[ERROR] {} (Code: {})", message, code),
|
||||
ErrorLevel::Warning => eprintln!("[WARNING] {} (Code: {})", message, code),
|
||||
ErrorLevel::Notice => eprintln!("[NOTICE] {}", message),
|
||||
_ => println!("{}", message)
|
||||
};
|
||||
}
|
|
@ -10,7 +10,7 @@ use rand::{Rng, thread_rng};
|
|||
use rand::distributions::Alphanumeric;
|
||||
use rayon::prelude::*;
|
||||
|
||||
use crate::logger::ErrorLevel::{Error, Log, Warning};
|
||||
use crate::logger::ErrorLevel::{Error, Log, Notice, Warning};
|
||||
use crate::logger::log;
|
||||
use crate::options::OverwritePolicy;
|
||||
|
||||
|
@ -53,6 +53,7 @@ fn main() {
|
|||
let mut compression_parameters = caesium::initialize_parameters();
|
||||
if opt.quality == 0 {
|
||||
compression_parameters.optimize = true;
|
||||
compression_parameters.png.force_zopfli = opt.zopfli;
|
||||
} else {
|
||||
compression_parameters.jpeg.quality = opt.quality;
|
||||
compression_parameters.png.quality = opt.quality;
|
||||
|
@ -72,6 +73,10 @@ fn main() {
|
|||
let overwrite_policy = opt.overwrite;
|
||||
let keep_structure = opt.keep_structure;
|
||||
|
||||
if opt.zopfli {
|
||||
log("Using zopfli may take a very long time, especially with large images!", 0, Notice, verbose);
|
||||
}
|
||||
|
||||
let progress_bar = setup_progress_bar(files.len() as u64, verbose);
|
||||
progress_bar.set_message("Compressing...");
|
||||
|
||||
|
|
|
@ -63,6 +63,10 @@ pub struct Opt {
|
|||
#[structopt(long, default_value = "0")]
|
||||
pub threads: u32,
|
||||
|
||||
/// use zopfli when optimizing PNG files (it may take a very long time to complete)
|
||||
#[structopt(long)]
|
||||
pub zopfli: bool,
|
||||
|
||||
/// select how much output you want to see, 0 is equal to -Q, --quiet
|
||||
#[structopt(long, default_value = "1")]
|
||||
pub verbose: u8,
|
||||
|
|
Loading…
Reference in New Issue