From 8b748115e55c993b1a3299fd48b38e1e49a1462b Mon Sep 17 00:00:00 2001 From: psykose Date: Sat, 30 Nov 2024 17:09:45 +0100 Subject: [PATCH] bufwrite --- src/ui/window.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ui/window.rs b/src/ui/window.rs index 884ade0..8998e9c 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -780,9 +780,12 @@ 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()); - let writer = std::fs::File::create(&save_path_copy)?; + + let file = std::fs::File::create(&save_path_copy)?; + let writer = std::io::BufWriter::new(file); + let encoder = - image::codecs::jpeg::JpegEncoder::new_with_quality(&writer, 95); + image::codecs::jpeg::JpegEncoder::new_with_quality(writer, 95); resized.write_with_encoder(encoder)?; *mpris_art_path = Some(save_path_copy); Ok(())