diff options
author | 2025-04-08 13:21:35 +0100 | |
---|---|---|
committer | 2025-04-08 13:21:35 +0100 | |
commit | 3abe88cd128b249f2038e13dbedcbd8341830126 (patch) | |
tree | b1832926b805fe495acbc7180b5ccdaf1dbfc5e1 /filamento/src/logic/online.rs | |
parent | e518e899e53c072724254bd714db914cde7db5b2 (diff) | |
download | luz-3abe88cd128b249f2038e13dbedcbd8341830126.tar.gz luz-3abe88cd128b249f2038e13dbedcbd8341830126.tar.bz2 luz-3abe88cd128b249f2038e13dbedcbd8341830126.zip |
fix(filamento): use jpeg for user avatar on avatar:data node
Diffstat (limited to 'filamento/src/logic/online.rs')
-rw-r--r-- | filamento/src/logic/online.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/filamento/src/logic/online.rs b/filamento/src/logic/online.rs index 5b57f84..d9441d7 100644 --- a/filamento/src/logic/online.rs +++ b/filamento/src/logic/online.rs @@ -1,4 +1,4 @@ -use std::io::Cursor; +use std::{io::Cursor, time::Duration}; use base64::{prelude::BASE64_STANDARD, Engine}; use chrono::Utc; @@ -897,7 +897,8 @@ pub async fn handle_change_avatar<Fs: FileStore + Clone>(logic: &ClientLogic<Fs> // convert the image to png; let mut data_png = Vec::new(); - image.write_to(&mut Cursor::new(&mut data_png), image::ImageFormat::Png)?; + let image = image.resize(192, 192, image::imageops::FilterType::Nearest); + image.write_to(&mut Cursor::new(&mut data_png), image::ImageFormat::Jpeg)?; // calculate the length of the data in bytes. let bytes = data_png.len().try_into()?; @@ -915,7 +916,7 @@ pub async fn handle_change_avatar<Fs: FileStore + Clone>(logic: &ClientLogic<Fs> logic.client().publish(pep::Item::AvatarData(Some(avatar::Data { hash: hash.clone(), data_b64 })), "urn:xmpp:avatar:data".to_string()).await?; // publish the metadata to the metadata node - logic.client().publish(pep::Item::AvatarMetadata(Some(avatar::Metadata { bytes, hash: hash.clone(), r#type: "image/png".to_string() })), "urn:xmpp:avatar:metadata".to_string()).await?; + logic.client().publish(pep::Item::AvatarMetadata(Some(avatar::Metadata { bytes, hash: hash.clone(), r#type: "image/jpeg".to_string() })), "urn:xmpp:avatar:metadata".to_string()).await?; // if everything went well, save the data to the disk. |