[repo] Format
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user