Baseline JPEG flag
This commit is contained in:
parent
4b45f33c92
commit
388536a7aa
|
@ -14,6 +14,17 @@
|
|||
|
||||
##### Advanced compression
|
||||
|
||||
- `--jpeg-chroma-subsampling <JPEG_CHROMA_SUBSAMPLING>`
|
||||
Sets the chroma subsampling for JPEG files. Possible values are:
|
||||
- `4:4:4`
|
||||
- `4:2:2`
|
||||
- `4:2:0`
|
||||
- `4:1:1`
|
||||
- `auto`
|
||||
|
||||
- `--jpeg-baseline`
|
||||
Forces the output to be in baseline JPEG format instead of progressive.
|
||||
|
||||
- `--png-opt-level <PNG_OPT_LEVEL>`
|
||||
Sets the optimization level for PNG files. Higher values result in better compression but take longer to complete.
|
||||
Possible values are between 0 and 6. Default is 3.
|
||||
|
|
|
@ -48,6 +48,7 @@ pub struct CompressionOptions {
|
|||
pub keep_dates: bool,
|
||||
pub keep_structure: bool,
|
||||
pub jpeg_chroma_subsampling: ChromaSubsampling,
|
||||
pub jpeg_baseline: bool,
|
||||
}
|
||||
|
||||
pub fn start_compression(
|
||||
|
@ -252,6 +253,7 @@ fn build_compression_parameters(
|
|||
parameters.keep_metadata = options.exif;
|
||||
|
||||
parameters.jpeg.chroma_subsampling = options.jpeg_chroma_subsampling;
|
||||
parameters.jpeg.progressive = !options.jpeg_baseline;
|
||||
|
||||
parameters.png.optimization_level = options.png_opt_level;
|
||||
parameters.png.force_zopfli = options.zopfli;
|
||||
|
@ -777,6 +779,7 @@ mod tests {
|
|||
exif: true,
|
||||
png_opt_level: 0,
|
||||
jpeg_chroma_subsampling: ChromaSubsampling::Auto,
|
||||
jpeg_baseline: false,
|
||||
zopfli: false,
|
||||
base_path: PathBuf::new(),
|
||||
}
|
||||
|
|
|
@ -139,6 +139,7 @@ fn build_compression_options(args: &CommandLineArgs, base_path: &Path) -> Compre
|
|||
exif: args.exif,
|
||||
png_opt_level: args.png_opt_level,
|
||||
jpeg_chroma_subsampling: parse_jpeg_chroma_subsampling(args.jpeg_chroma_subsampling),
|
||||
jpeg_baseline: args.jpeg_baseline,
|
||||
zopfli: args.zopfli,
|
||||
base_path: PathBuf::from(base_path),
|
||||
}
|
||||
|
|
|
@ -53,10 +53,14 @@ pub struct CommandLineArgs {
|
|||
#[arg(long, default_value = "3")]
|
||||
pub png_opt_level: u8,
|
||||
|
||||
/// select level for PNG optimization, between [0-6]
|
||||
/// select the chroma subsampling for JPEG files
|
||||
#[arg(long, value_enum, default_value = "auto")]
|
||||
pub jpeg_chroma_subsampling: JpegChromaSubsampling,
|
||||
|
||||
/// output a baseline JPEG file, progressive (default) otherwise
|
||||
#[arg(long)]
|
||||
pub jpeg_baseline: bool,
|
||||
|
||||
/// use zopfli when optimizing PNG files (it may take a very long time to complete)
|
||||
#[arg(long)]
|
||||
pub zopfli: bool,
|
||||
|
|
Loading…
Reference in New Issue