feat: better quality of image recoding (#8682)

this PR introduces a better quality of image recoding, consuming max.
900k instead of 500k (average is much less). the PR roughly doubles the
number of pixels sent in an image.

the old 1280px were set 8 years ago,
data and storage has improved since then,
so it is reasonable to double the number if pixels used for sending an
image.

this will be a quality boost for many images,
while not resulting in a doubled size for all of them; many images will
only be a little larger in bytes, see test.

we could always go higher, of course, but it comes at costs of relay
storage and data, so we stay conservative, even in that increase.

the "worse quality" setting is not adapted on purpose, there we really
stay at the end of what is bearable :)

cc @adbenitez

---------

Co-authored-by: l <link2xt@testrun.org>
This commit is contained in:
biørn
2026-09-12 13:44:02 +00:00
committed by GitHub
co-authored by l
parent 9e8c3a63ad
commit 0b2051cda4
6 changed files with 14 additions and 13 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ async fn test_additional_text_on_different_viewtypes() -> Result<()> {
let (pre_message, _, _) = send_large_image_message(alice, a_group_id).await?;
let msg = bob.recv_msg(&pre_message).await;
assert_eq!(msg.text, "test".to_owned());
assert_eq!(msg.get_text(), "test [Image – 228.45 KiB]".to_owned());
assert_eq!(msg.get_text(), "test [Image – 275.46 KiB]".to_owned());
Ok(())
}
+3 -3
View File
@@ -501,9 +501,9 @@ async fn test_receive_pre_message_image() -> Result<()> {
// test that metadata is correctly returned by methods
assert_eq!(msg.get_post_message_viewtype(), Some(Viewtype::Image));
// recoded image dimensions
assert_eq!(msg.get_filebytes(bob).await?, Some(233935));
assert_eq!(msg.get_height(), 1704);
assert_eq!(msg.get_width(), 959);
assert_eq!(msg.get_filebytes(bob).await?, Some(282068));
assert_eq!(msg.get_height(), 1920);
assert_eq!(msg.get_width(), 1080);
Ok(())
}