diff --git a/quickpeep_raker/src/raking.rs b/quickpeep_raker/src/raking.rs index 53070e5..d4e1c36 100644 --- a/quickpeep_raker/src/raking.rs +++ b/quickpeep_raker/src/raking.rs @@ -5,6 +5,7 @@ use chrono::{DateTime, FixedOffset, Utc}; use cylon::Cylon; use futures_util::stream::StreamExt; use html5ever::tendril::fmt::Slice; +use image::imageops::FilterType; use image::{GenericImageView, ImageFormat}; use itertools::Itertools; use lazy_static::lazy_static; @@ -510,15 +511,22 @@ pub fn rake_icon(content: &[u8], content_type: &str) -> anyhow::Result WANTED_DIMENSIONS { - image = image.thumbnail(WANTED_DIMENSIONS, WANTED_DIMENSIONS); + // image = image.thumbnail(WANTED_DIMENSIONS, WANTED_DIMENSIONS); + // Triangle is slightly better quality than nearest neighbour, but less expensive than + // Cubic or Lanczos. + // .thumbnail() is apparently very fast, but the artifacts were a little bit unfortunate for + // this. + image = image.resize_to_fill(WANTED_DIMENSIONS, WANTED_DIMENSIONS, FilterType::Triangle); } let webp_encoder = webp::Encoder::from_image(&image).map_err(|err| anyhow!("webp fail: {}", err))?; - let encoded = webp_encoder.encode(0.6).to_vec(); + let encoded = webp_encoder.encode(WEBP_QUALITY).to_vec(); Ok(RakedIcon { original_size_in_bytes: orig_size,