chatmail / chatmail/core

screenshots are sometimes sent in poor quality

Open
#7,977 2 comments 0 reactions 1 assignee Claimed by @iequidoo View on GitHub
enhancement image-quality
Dominant language
Rust
Stars
929
Forks
143
Avg merge
1d 20h
Merged PRs (30d)
53

Description

to send images, we scale them down to ~ 1280px width and jpg-compress them under 500k. if the image is still larger, we try over with a smaller size. avatar work similar with different constraints.

in many situations, this is a good approach, even for screenshots, refined recently a lot https://github.com/chatmail/core/pulls?q=is%3Apr+image

however, if you have a larger screenshot on desktop, with a good part of photo and another good part of text, the outgoing image looks bad.

the conversion png -> jpg is of course part of the quality loss, however needed to get [images in a compatible way small at all](https://github.com/chatmail/core/issues/3956#issuecomment-1382725717), there were some measurements in the past, that part is really needed. done also by apple, btw.

main reason for the poor quality is the scaling down, and that by that the quality.

so, maybe do the following:

- if an image to sent is _not_ jpg, try first to send it with far larger dimensions, eg 4096 px. only if this gets a too large file, try over with a smaller size. this was suggested already at https://github.com/chatmail/core/issues/3956, but not done that time for $reasons

- using really the original dimensions is risky, as there are png around with eg. tens of 10000 px sides. this is also not the issue at hand

- we should not do that approach for images that are already jpg, as this is not the issue at hand, and likely results in side effects. it will also increase overall data usage

## example

eg. the following 1618 x 949 px, 1.1 mb png-image:

Image

sending the image with Delta Chat results in a 1280 x 751 px 79 kb jpg-image:

![Image](https://github.com/user-attachments/assets/423bb4d6-ba44-41b1-8622-b5ed3707e559)

if you convert the image in its original size to jpg, using the same 75% quality setting, which still seems to be inside the sweet spot, it is far better - while being 114 kb only:

![Image](https://github.com/user-attachments/assets/8b0329e6-4279-4853-94ca-d3728ff2783d)

sure, _that_ specific image can be improved further. but goal is to have an overall, simple approach, that does not make all images larger that would not need it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.