diff options
Diffstat (limited to '')
-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. |