Skip to content

Commit 1b8c732

Browse files
authored
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 in b7864f2. 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`](https://github.com/72374/core/blob/a6b2a54e46157dd6694146bb9f109eb2c60462ef/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.
1 parent 2531dfe commit 1b8c732

1 file changed

Lines changed: 0 additions & 10 deletions

File tree

src/blob.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! # Blob directory management.
22
3-
use core::cmp::max;
43
use std::io::{Cursor, Seek};
54
use std::iter::FusedIterator;
65
use std::mem;
@@ -425,15 +424,6 @@ impl<'a> BlobObject<'a> {
425424
});
426425

427426
if do_scale {
428-
if !exceeds_wh {
429-
img_wh = max(img.width(), img.height());
430-
// PNGs and WebPs may be huge because of animation, which is lost by the `image`
431-
// crate when recoding, so don't scale them down.
432-
if matches!(fmt, ImageFormat::Jpeg) || !encoded.is_empty() {
433-
img_wh = img_wh * 2 / 3;
434-
}
435-
}
436-
437427
loop {
438428
if mem::take(&mut add_white_bg) {
439429
self::add_white_bg(&mut img);

0 commit comments

Comments
 (0)