Fast image scaling.

Use the new image.thumbnail method if the source is at least three
times target size.
This commit is contained in:
Rasmus Kaj 2018-04-27 11:01:59 +02:00
parent fb766f5a0d
commit 79ca4a4e1a

View File

@ -24,7 +24,9 @@ impl PhotosDir {
let path = self.basedir.join(&photo.path);
info!("Should open {:?}", path);
let img = image::open(path)?;
let img = if width < img.width() || height < img.height() {
let img = if 3 * width <= img.width() || 3 * height <= img.height() {
img.thumbnail(width, height)
} else if width < img.width() || height < img.height() {
img.resize(width, height, FilterType::CatmullRom)
} else {
img