update smartcrop2 to v0.4.0, remove black borders from album covers

This commit is contained in:
ThetaDev 2025-03-04 22:38:01 +01:00
parent 144a670da1
commit 6d481c16d0
No known key found for this signature in database
GPG key ID: E319D3C5148D65B6
2 changed files with 8 additions and 4 deletions

View file

@ -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

View file

@ -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(