[repo] Format

This commit is contained in:
2026-11-17 00:57:06 +01:00
parent f1f0234ffb
commit 6efc835d24
5 changed files with 1139 additions and 1068 deletions
+13 -3
View File
@@ -42,7 +42,9 @@ struct Step {
fn steps(preset: CompressPreset) -> &'static [Step] {
match preset {
CompressPreset::Email => &[Step { dpi: 120.0, quality: 62 }, Step { dpi: 96.0, quality: 55 }, Step { dpi: 72.0, quality: 50 }],
CompressPreset::Email => {
&[Step { dpi: 120.0, quality: 62 }, Step { dpi: 96.0, quality: 55 }, Step { dpi: 72.0, quality: 50 }]
}
CompressPreset::Web => &[Step { dpi: 150.0, quality: 72 }],
CompressPreset::Print => &[Step { dpi: 300.0, quality: 86 }],
}
@@ -195,7 +197,11 @@ fn recompress(doc: &Document, s: &Stream, max_px: u32, quality: u8) -> Option<St
i
}
b"FlateDecode" | b"" => {
let raw = if filter.is_empty() { s.content.clone() } else { s.decompressed_content_with_limit(600 << 20).ok()? };
let raw = if filter.is_empty() {
s.content.clone()
} else {
s.decompressed_content_with_limit(600 << 20).ok()?
};
let need = (w as usize) * (h as usize) * n as usize;
if raw.len() < need {
return None;
@@ -210,7 +216,11 @@ fn recompress(doc: &Document, s: &Stream, max_px: u32, quality: u8) -> Option<St
let (iw, ih) = img.dimensions();
let img = if iw.max(ih) > max_px + max_px / 10 {
let k = max_px as f32 / iw.max(ih) as f32;
img.resize_exact(((iw as f32 * k).round() as u32).max(1), ((ih as f32 * k).round() as u32).max(1), image::imageops::FilterType::Lanczos3)
img.resize_exact(
((iw as f32 * k).round() as u32).max(1),
((ih as f32 * k).round() as u32).max(1),
image::imageops::FilterType::Lanczos3,
)
} else {
img
};