feat: Don't scale down huge non-JPEGs, recode them first (#7977)

If after recoding to JPEG an image isn't huge anymore, don't scale it down, this preserves quality
of most screenshots. For JPEGs however we don't try to recode them w/o scaling down:
- They are already JPEG-encoded, maybe with higher quality, but anyway.
- We don't want extra CPU work for most photos.
This commit is contained in:
iequidoo
2026-03-15 09:53:40 -03:00
parent 942172a31a
commit 2e7e8c35da
5 changed files with 40 additions and 6 deletions

View File

@@ -462,6 +462,26 @@ async fn test_recode_image_balanced_png() {
.unwrap();
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_recode_image_balanced_png_huge() {
let bytes = include_bytes!("../../test-data/image/screenshot-huge.png");
SendImageCheckMediaquality {
viewtype: Viewtype::Image,
media_quality_config: "0",
bytes,
extension: "jpg",
original_width: 1618,
original_height: 949,
compressed_width: 1618,
compressed_height: 949,
..Default::default()
}
.test()
.await
.unwrap();
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_sticker_with_exif() {
let bytes = include_bytes!("../../test-data/image/logo-exif.png");