-
-
Notifications
You must be signed in to change notification settings - Fork 110
Compress avatar to below 20k #2384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d35795a to
f79c652
Compare
…ve the problem that JPEGs are saved as PNGs now though
src/blob.rs
Outdated
| mut blob_abs: PathBuf, | ||
| mut img_wh: u32, | ||
| max_bytes: Option<usize>, | ||
| ) -> Result<String, BlobError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to explicitly return Option<String> and use None instead of special empty string value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have pushed this change to this branch
|
nice, just sent avatars with outlook :) |
Currently, group images are compressed as well because it was easier to implement that way.
Currently, in the unlikely case that the avatar is compressed down to 20x20 pixels but still bigger than 20KB, the user doesn't get any indication of this, the avatar simply isn't changed (at least on Android).
If we want to change this, the easiest way is probably to let
dc_set_config()in the ffi callerror!()ifSelfavatarcan't be set. The same might make sense for some or all other configs. BUUUUUT: At least Android doesn't show error!() toasts anymore, probably because they were used too often and too spammy.The factor by which we scale down if the file is too big is 1.5.
I hope everything is clear 😂 there were surprisingly many small problems.