Skip to content

Commit 7056e24

Browse files
committed
2squash: Increase received images size limit to 35 Mpx
+ Rename it to MAX_RCVD_IMAGE_PIXELS to make it clear that sending isn't affected. + Add a doc comment.
1 parent 6786a9b commit 7056e24

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/constants.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ pub(crate) const WORSE_AVATAR_BYTES: usize = 20_000; // this also fits to Outloo
193193
pub const BALANCED_IMAGE_SIZE: u32 = 1280;
194194
pub const WORSE_IMAGE_SIZE: u32 = 640;
195195

196-
// Limit displayed images ~8.3 megapixels (3840 × 2160)
197-
pub const MAX_IMAGE_PIXELS: u32 = 8294400;
196+
/// Limit for received images size. Bigger images become `Viewtype::File` to avoid excessive memory
197+
/// usage by UIs.
198+
pub const MAX_RCVD_IMAGE_PIXELS: u32 = 35_000_000;
198199

199200
// Key for the folder configuration version (see below).
200201
pub(crate) const DC_FOLDERS_CONFIGURED_KEY: &str = "folders_configured";

src/mimeparser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ impl MimeMessage {
13861386
{
13871387
match get_filemeta(decoded_data) {
13881388
// image size is known, not too big, keep msg_type:
1389-
Ok((width, height)) if width * height <= constants::MAX_IMAGE_PIXELS => {
1389+
Ok((width, height)) if width * height <= constants::MAX_RCVD_IMAGE_PIXELS => {
13901390
part.param.set_i64(Param::Width, width.into());
13911391
part.param.set_i64(Param::Height, height.into());
13921392
msg_type

0 commit comments

Comments
 (0)