From eb5c6d03d33f45aa07eb24e8707a25a98e1b60d3 Mon Sep 17 00:00:00 2001 From: 72374 <250991390+72374@users.noreply.github.com> Date: Fri, 13 Mar 2026 14:57:20 +0100 Subject: [PATCH 1/2] feat: Increase the resolution-limit `WORSE_AVATAR_SIZE` from 128 to 256 The file-size of many images will already be smaller than 20 kB, when encoded at 256x256, and it can be a large improvement in quality. --- src/constants.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants.rs b/src/constants.rs index 1eb852b348..d89f2f1289 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -199,7 +199,7 @@ pub const WORSE_IMAGE_BYTES: usize = 130_000; // max. width/height and bytes of an avatar pub(crate) const BALANCED_AVATAR_SIZE: u32 = 512; pub(crate) const BALANCED_AVATAR_BYTES: usize = 60_000; -pub(crate) const WORSE_AVATAR_SIZE: u32 = 128; +pub(crate) const WORSE_AVATAR_SIZE: u32 = 256; pub(crate) const WORSE_AVATAR_BYTES: usize = 20_000; // this also fits to Outlook servers don't allowing headers larger than 32k. // max. width/height of images scaled down because of being too huge From ed7ffdf7f391e3ff4123aebcab60346c679ff70e Mon Sep 17 00:00:00 2001 From: 72374 <250991390+72374@users.noreply.github.com> Date: Wed, 4 Feb 2026 01:00:04 +0100 Subject: [PATCH 2/2] feat: Change multiplier to 7/8 when scaling down avatars The resolution-limits for avatar-images are currently 512x512 or 256x256. Reducing the resolution further, to 2/3 each step, can reduce the quality much more than is necessary to fit within the file-size-limits, which are currently 60 kB or 20 kB. An image made entirely of noise (which results in unusually large file-sizes), encoded with jpeg-quality 75, and 4:2:2-colour-subsampling (the format currently used for encoding images), can be below 60 kB at 227x227. For the lower file-size-limit of 20 kB, such images can be too large at 170x170, but fit at 149x149. More normal images will have a lower file-size at the same resolution. Before this change, the target-resolutions for resampling were: 512x512 -> 341x341 -> 227x227. And for the lower file-size-limit: 256x256 -> 170x170 -> 113x113. After this change, the target-resolutions for resampling will be: 512x512 -> 448x448 -> 392x392 -> 343x343 -> 300x300 -> 262x262 -> 229x229. And for the lower file-size-limit, those will be: 256x256 -> 224x224 -> 196x196 -> 171x171 -> 149x149 -> 130x130 -> 113x113. This does add 2 steps between the previous target-resolutions, while still reaching target-resolutions close to the previous ones, to reduce situations in which the quality will be lower than before. --- src/blob.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blob.rs b/src/blob.rs index 27c44f3e31..46f70a9b2e 100644 --- a/src/blob.rs +++ b/src/blob.rs @@ -468,7 +468,7 @@ impl<'a> BlobObject<'a> { )); } - target_wh = target_wh * 2 / 3; + target_wh = target_wh * 7 / 8; } else { info!( context,