mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
fix: Do not additionally reduce the resolution of images that fit into the resolution-limit and are larger than the file-size-limit (#7760)
See: https://support.delta.chat/t/high-quality-avatar/1052/8 This removes an additional resolution-reduction for images that fit within the resolution-limit. The additional reduction of the image-resolution was added inb7864f232b. It seems that back then only resolution-reduction was used to make the file-size of images smaller, and the purpose was to skip an unnecessary encoding-step. However, encoding images with [jpeg-quality set to `75`](a6b2a54e46/src/blob.rs (L392)), as it is currently done, can significantly reduce the file-size, even if the resolution is the same. As the resolution of the image that will be encoded is rather low when it fits within the resolution-limit, further reducing it can significantly reduce the quality of the image. Thus it is better to not skip the encoding-step at the original resolution.
This commit is contained in:
10
src/blob.rs
10
src/blob.rs
@@ -1,6 +1,5 @@
|
||||
//! # Blob directory management.
|
||||
|
||||
use core::cmp::max;
|
||||
use std::io::{Cursor, Seek};
|
||||
use std::iter::FusedIterator;
|
||||
use std::mem;
|
||||
@@ -425,15 +424,6 @@ impl<'a> BlobObject<'a> {
|
||||
});
|
||||
|
||||
if do_scale {
|
||||
if !exceeds_wh {
|
||||
img_wh = max(img.width(), img.height());
|
||||
// PNGs and WebPs may be huge because of animation, which is lost by the `image`
|
||||
// crate when recoding, so don't scale them down.
|
||||
if matches!(fmt, ImageFormat::Jpeg) || !encoded.is_empty() {
|
||||
img_wh = img_wh * 2 / 3;
|
||||
}
|
||||
}
|
||||
|
||||
loop {
|
||||
if mem::take(&mut add_white_bg) {
|
||||
self::add_white_bg(&mut img);
|
||||
|
||||
Reference in New Issue
Block a user