From 473c7ef7e54516a3728f44502e77560cd54b54e5 Mon Sep 17 00:00:00 2001 From: psykose Date: Sat, 30 Nov 2024 14:14:03 +0100 Subject: [PATCH] jpeg quality, sooner drop --- Cargo.toml | 1 - src/mpris/player.rs | 14 +++++++------- src/ui/window.rs | 5 ++++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f96f49c..d0ef207 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -81,4 +81,3 @@ panic = "abort" [profile.bench] debug = true -panic = "abort" diff --git a/src/mpris/player.rs b/src/mpris/player.rs index 2f59010..8f4878f 100644 --- a/src/mpris/player.rs +++ b/src/mpris/player.rs @@ -159,6 +159,13 @@ impl Player { let mpris_art_path = audrey::globals::MPRIS_ART_PATH.lock().await; if let Some(song) = self.window().song() { + if let Some(path) = mpris_art_path.as_ref() { + map.insert( + "mpris:artUrl", + (url::Url::from_file_path(path).unwrap().to_string()).into(), + ); + } + drop(mpris_art_path); map.insert( "mpris:trackid", format!("/eu/callcc/audrey/Track/{}", song.counter()).into(), @@ -167,13 +174,6 @@ impl Player { "mpris:length", ((self.window().duration() * MICROSECONDS) as i64).into(), ); - if let Some(path) = mpris_art_path.as_ref() { - map.insert( - "mpris:artUrl", - (url::Url::from_file_path(path).unwrap().to_string()).into(), - ); - } - drop(mpris_art_path); map.insert("xesam:album", song.album().into()); // TODO: use the right opensubsonic data map.insert("xesam:artist", vec![song.artist()].into()); diff --git a/src/ui/window.rs b/src/ui/window.rs index 29d7468..884ade0 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -780,7 +780,10 @@ mod imp { image_copy.resize(400, 400, image::imageops::FilterType::Lanczos3); // resize reoutputs rgba image; we can't save an rgba jpeg let resized = image::DynamicImage::ImageRgb8(resized.into()); - resized.save_with_format(&save_path_copy, image::ImageFormat::Jpeg)?; + let writer = std::fs::File::create(&save_path_copy)?; + let encoder = + image::codecs::jpeg::JpegEncoder::new_with_quality(&writer, 95); + resized.write_with_encoder(encoder)?; *mpris_art_path = Some(save_path_copy); Ok(()) },