mirror of
https://github.com/chatmail/core.git
synced 2026-05-12 19:36:32 +03:00
fix review comments
This commit is contained in:
19
src/blob.rs
19
src/blob.rs
@@ -372,14 +372,12 @@ impl<'a> BlobObject<'a> {
|
|||||||
let mut encoded = Vec::new();
|
let mut encoded = Vec::new();
|
||||||
let mut changed_name = None;
|
let mut changed_name = None;
|
||||||
|
|
||||||
if matches!(orientation, Some(90) | Some(180) | Some(270)) {
|
img = match orientation {
|
||||||
img = match orientation {
|
Some(90) => img.rotate90(),
|
||||||
Some(90) => img.rotate90(),
|
Some(180) => img.rotate180(),
|
||||||
Some(180) => img.rotate180(),
|
Some(270) => img.rotate270(),
|
||||||
Some(270) => img.rotate270(),
|
_ => img,
|
||||||
_ => img,
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let exceeds_wh = img.width() > img_wh || img.height() > img_wh;
|
let exceeds_wh = img.width() > img_wh || img.height() > img_wh;
|
||||||
let exceeds_max_bytes = nr_bytes > max_bytes as u64;
|
let exceeds_max_bytes = nr_bytes > max_bytes as u64;
|
||||||
@@ -387,7 +385,10 @@ impl<'a> BlobObject<'a> {
|
|||||||
let fmt = ImageFormat::from_path(&blob_abs);
|
let fmt = ImageFormat::from_path(&blob_abs);
|
||||||
let ofmt = match fmt {
|
let ofmt = match fmt {
|
||||||
Ok(ImageFormat::Png) if !exceeds_max_bytes => ImageOutputFormat::Png,
|
Ok(ImageFormat::Png) if !exceeds_max_bytes => ImageOutputFormat::Png,
|
||||||
_ => ImageOutputFormat::Jpeg(75),
|
_ => {
|
||||||
|
let jpeg_quality = 75;
|
||||||
|
ImageOutputFormat::Jpeg(jpeg_quality)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// We need to rewrite images with Exif to remove metadata such as location,
|
// We need to rewrite images with Exif to remove metadata such as location,
|
||||||
// camera model, etc.
|
// camera model, etc.
|
||||||
|
|||||||
Reference in New Issue
Block a user