update smartcrop2 to v0.4.0, remove black borders from album covers
This commit is contained in:
parent
144a670da1
commit
6d481c16d0
2 changed files with 8 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Reference in a new issue