Skip to content

Commit 79286ef

Browse files
committed
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.
1 parent 196a4a7 commit 79286ef

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/blob.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ impl<'a> BlobObject<'a> {
480480
));
481481
}
482482

483-
target_wh = target_wh * 2 / 3;
483+
target_wh = target_wh * 7 / 8;
484484
} else {
485485
info!(
486486
context,

0 commit comments

Comments
 (0)