mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-06-08 13:58:50 +08:00
Add option to set png compression level
This commit is contained in:
31
src/types.rs
31
src/types.rs
@@ -237,6 +237,8 @@ pub struct ExtraConfig {
|
||||
pub cat_system_cstl_lang: Option<String>,
|
||||
#[cfg(feature = "flate2")]
|
||||
pub zlib_compression_level: Option<u32>,
|
||||
#[cfg(feature = "image")]
|
||||
pub png_compression_level: PngCompressionLevel,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, ValueEnum, PartialEq, Eq, PartialOrd, Ord)]
|
||||
@@ -484,3 +486,32 @@ impl BomType {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "image")]
|
||||
#[derive(Clone, Copy, Debug, ValueEnum, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum PngCompressionLevel {
|
||||
#[value(alias = "d")]
|
||||
/// Default level
|
||||
Default,
|
||||
#[value(alias = "f")]
|
||||
/// Fast minimal compression
|
||||
Fast,
|
||||
#[value(alias = "b")]
|
||||
/// Higher compression level
|
||||
///
|
||||
/// Best in this context isn't actually the highest possible level
|
||||
/// the encoder can do, but is meant to emulate the `Best` setting in the `Flate2`
|
||||
/// library.
|
||||
Best,
|
||||
}
|
||||
|
||||
#[cfg(feature = "image")]
|
||||
impl PngCompressionLevel {
|
||||
pub fn to_compression(&self) -> png::Compression {
|
||||
match self {
|
||||
PngCompressionLevel::Default => png::Compression::Default,
|
||||
PngCompressionLevel::Fast => png::Compression::Fast,
|
||||
PngCompressionLevel::Best => png::Compression::Best,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user