From 3abe88cd128b249f2038e13dbedcbd8341830126 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Tue, 8 Apr 2025 13:21:35 +0100 Subject: fix(filamento): use jpeg for user avatar on avatar:data node --- filamento/src/logic/online.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'filamento/src/logic/online.rs') 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(logic: &ClientLogic // 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(logic: &ClientLogic 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. -- cgit