Wire progressive JPEG, AVIF speed, and custom per-format quality to encoder
This commit is contained in:
@@ -4,7 +4,7 @@ use std::time::Instant;
|
||||
|
||||
use rayon::prelude::*;
|
||||
|
||||
use crate::encoder::OutputEncoder;
|
||||
use crate::encoder::{EncoderOptions, OutputEncoder};
|
||||
use crate::error::{PixstripError, Result};
|
||||
use crate::loader::ImageLoader;
|
||||
use crate::operations::adjustments::apply_adjustments;
|
||||
@@ -182,7 +182,10 @@ impl PipelineExecutor {
|
||||
});
|
||||
|
||||
let loader = ImageLoader::new();
|
||||
let encoder = OutputEncoder::new();
|
||||
let encoder = OutputEncoder::with_options(EncoderOptions {
|
||||
progressive_jpeg: job.progressive_jpeg,
|
||||
avif_speed: job.avif_speed,
|
||||
});
|
||||
|
||||
match Self::process_single_static(job, source, &loader, &encoder, idx) {
|
||||
Ok((in_size, out_size)) => {
|
||||
@@ -237,7 +240,10 @@ impl PipelineExecutor {
|
||||
let start = Instant::now();
|
||||
let total = job.sources.len();
|
||||
let loader = ImageLoader::new();
|
||||
let encoder = OutputEncoder::new();
|
||||
let encoder = OutputEncoder::with_options(EncoderOptions {
|
||||
progressive_jpeg: job.progressive_jpeg,
|
||||
avif_speed: job.avif_speed,
|
||||
});
|
||||
|
||||
let mut result = BatchResult {
|
||||
total,
|
||||
@@ -368,12 +374,14 @@ impl PipelineExecutor {
|
||||
}
|
||||
crate::operations::CompressConfig::Custom {
|
||||
jpeg_quality,
|
||||
png_level: _,
|
||||
png_level,
|
||||
webp_quality,
|
||||
avif_quality: _,
|
||||
avif_quality,
|
||||
} => match output_format {
|
||||
ImageFormat::Jpeg => jpeg_quality.unwrap_or(85),
|
||||
ImageFormat::Png => png_level.unwrap_or(6),
|
||||
ImageFormat::WebP => webp_quality.map(|q| q as u8).unwrap_or(80),
|
||||
ImageFormat::Avif => avif_quality.map(|q| q as u8).unwrap_or(50),
|
||||
_ => 85,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user