update smartcrop2 to v0.4.0, remove black borders from album covers
This commit is contained in:
parent
965d76472b
commit
fb76c85472
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",
|
"jpeg",
|
||||||
"webp",
|
"webp",
|
||||||
] }
|
] }
|
||||||
smartcrop2 = { version = "0.3.1", optional = true }
|
smartcrop2 = { version = "0.4.0", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
path_macro.workspace = true
|
path_macro.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -1033,9 +1033,13 @@ impl DownloadQuery {
|
||||||
image::load_from_memory(&img_bts)?
|
image::load_from_memory(&img_bts)?
|
||||||
};
|
};
|
||||||
|
|
||||||
let crop = smartcrop::find_best_crop(&img, NonZeroU32::MIN, NonZeroU32::MIN)
|
let crop = smartcrop::find_best_crop_no_borders(
|
||||||
.map_err(|e| DownloadError::AudioTag(format!("image crop: {e}").into()))?
|
&img,
|
||||||
.crop;
|
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);
|
img = img.crop_imm(crop.x, crop.y, crop.width, crop.height);
|
||||||
let mut enc_bts = Vec::new();
|
let mut enc_bts = Vec::new();
|
||||||
img.write_with_encoder(image::codecs::jpeg::JpegEncoder::new_with_quality(
|
img.write_with_encoder(image::codecs::jpeg::JpegEncoder::new_with_quality(
|
||||||
|
|
|
||||||
Reference in a new issue