Skip to content

Make avatar-image-quality more consistent#8010

Merged
Hocuri merged 2 commits intochatmail:mainfrom
72374:make-avatar-image-quality-more-consistent
Apr 15, 2026
Merged

Make avatar-image-quality more consistent#8010
Hocuri merged 2 commits intochatmail:mainfrom
72374:make-avatar-image-quality-more-consistent

Conversation

@72374
Copy link
Copy Markdown
Contributor

@72374 72374 commented Mar 18, 2026

See commit-descriptions for details.


I moved these 2 commits from #7822 into this PR, to make it easier to review.

72374 added 2 commits March 18, 2026 16:08
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.
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.
Comment thread src/blob.rs
}

target_wh = target_wh * 2 / 3;
target_wh = target_wh * 7 / 8;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to change this anyway in #7827 because using multipliers like 49/64 isn't great, they add more aliasing effect than 6/8 (which is 48/64), it's better to lose ~2% of the image size. Anyway, this is already better than 2/3.

@iequidoo iequidoo requested a review from Hocuri March 19, 2026 09:58
Copy link
Copy Markdown
Collaborator

@Hocuri Hocuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the endurance, and sorry that this took so long! Usually we're faster with looking at PRs, but we had some features to deliver which pushed everything else back in the list of priorities, and we're now starting to work through the backlog.

I tested this on my 5 years old middle-class phone, and even in battery saver mode, it was reasonably fast, so, this seems like a clear improvement, thanks!

@Hocuri
Copy link
Copy Markdown
Collaborator

Hocuri commented Apr 15, 2026

FTR, CI is failing because it doesn't work for outside contributors, unfortunately. I'm just going to merge this anyways, because this doesn't touch any code that is tested by the failing tests.

@Hocuri Hocuri merged commit 9adb71b into chatmail:main Apr 15, 2026
23 of 30 checks passed
@72374 72374 deleted the make-avatar-image-quality-more-consistent branch April 15, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants