From 6d481c16d0c67194ac84b886d3923f885bbd4a89 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Tue, 4 Mar 2025 22:38:01 +0100 Subject: [PATCH] update smartcrop2 to v0.4.0, remove black borders from album covers --- downloader/Cargo.toml | 2 +- downloader/src/lib.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/downloader/Cargo.toml b/downloader/Cargo.toml index 6af966f..dba74ce 100644 --- a/downloader/Cargo.toml +++ b/downloader/Cargo.toml @@ -51,7 +51,7 @@ image = { version = "0.25.0", optional = true, default-features = false, feature "jpeg", "webp", ] } -smartcrop2 = { version = "0.3.1", optional = true } +smartcrop2 = { version = "0.4.0", optional = true } [dev-dependencies] path_macro.workspace = true diff --git a/downloader/src/lib.rs b/downloader/src/lib.rs index 8dc00c0..58d124d 100644 --- a/downloader/src/lib.rs +++ b/downloader/src/lib.rs @@ -1033,9 +1033,13 @@ impl DownloadQuery { image::load_from_memory(&img_bts)? }; - let crop = smartcrop::find_best_crop(&img, NonZeroU32::MIN, NonZeroU32::MIN) - .map_err(|e| DownloadError::AudioTag(format!("image crop: {e}").into()))? - .crop; + let crop = smartcrop::find_best_crop_no_borders( + &img, + NonZeroU32::MIN, + NonZeroU32::MIN, + ) + .map_err(|e| DownloadError::AudioTag(format!("image crop: {e}").into()))? + .crop; img = img.crop_imm(crop.x, crop.y, crop.width, crop.height); let mut enc_bts = Vec::new(); img.write_with_encoder(image::codecs::jpeg::JpegEncoder::new_with_quality(