fix: media thumbnail calculation and appservice detection

This commit is contained in:
Timo Kösters 2021-03-23 19:46:54 +01:00
parent 3ea7d162db
commit 46d8f36a2c
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
5 changed files with 29 additions and 13 deletions

View file

@ -226,16 +226,17 @@ impl Media {
}
let thumbnail = if crop {
image.resize_to_fill(width, height, FilterType::Triangle)
image.resize_to_fill(width, height, FilterType::CatmullRom)
} else {
let (exact_width, exact_height) = {
// Copied from image::dynimage::resize_dimensions
let ratio = u64::from(original_width) * u64::from(height);
let nratio = u64::from(width) * u64::from(original_height);
let use_width = nratio > ratio;
let use_width = nratio <= ratio;
let intermediate = if use_width {
u64::from(original_height) * u64::from(width) / u64::from(width)
u64::from(original_height) * u64::from(width)
/ u64::from(original_width)
} else {
u64::from(original_width) * u64::from(height)
/ u64::from(original_height)
@ -261,7 +262,7 @@ impl Media {
}
};
image.thumbnail_exact(exact_width, exact_height)
image.thumbnail_exact(dbg!(exact_width), dbg!(exact_height))
};
let mut thumbnail_bytes = Vec::new();