jpeg quality, sooner drop

This commit is contained in:
psykose 2024-11-30 14:14:03 +01:00
parent 9935a502ac
commit 473c7ef7e5
Signed by: psykose
SSH key fingerprint: SHA256:pRMVjV3kRB6zl+wNx+sV8KoMnPqQAW6v8dNCxsCGZv8
3 changed files with 11 additions and 9 deletions

View file

@ -81,4 +81,3 @@ panic = "abort"
[profile.bench] [profile.bench]
debug = true debug = true
panic = "abort"

View file

@ -159,6 +159,13 @@ impl Player {
let mpris_art_path = audrey::globals::MPRIS_ART_PATH.lock().await; let mpris_art_path = audrey::globals::MPRIS_ART_PATH.lock().await;
if let Some(song) = self.window().song() { 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( map.insert(
"mpris:trackid", "mpris:trackid",
format!("/eu/callcc/audrey/Track/{}", song.counter()).into(), format!("/eu/callcc/audrey/Track/{}", song.counter()).into(),
@ -167,13 +174,6 @@ impl Player {
"mpris:length", "mpris:length",
((self.window().duration() * MICROSECONDS) as i64).into(), ((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()); map.insert("xesam:album", song.album().into());
// TODO: use the right opensubsonic data // TODO: use the right opensubsonic data
map.insert("xesam:artist", vec![song.artist()].into()); map.insert("xesam:artist", vec![song.artist()].into());

View file

@ -780,7 +780,10 @@ mod imp {
image_copy.resize(400, 400, image::imageops::FilterType::Lanczos3); image_copy.resize(400, 400, image::imageops::FilterType::Lanczos3);
// resize reoutputs rgba image; we can't save an rgba jpeg // resize reoutputs rgba image; we can't save an rgba jpeg
let resized = image::DynamicImage::ImageRgb8(resized.into()); 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); *mpris_art_path = Some(save_path_copy);
Ok(()) Ok(())
}, },