auto-thumbnail 0.2.0

Converts various file formats into thumbnail image.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use std::path::Path;

use crate::decode;

pub(crate) fn create_thumbnail<P>(path: P, width: u32, height: u32) -> anyhow::Result<::image::DynamicImage>
where
    P: AsRef<Path>,
{
    let path = path.as_ref();
    let max_dim = width.max(height);
    let img = decode::decode_and_thumbnail(path, max_dim)?;
    Ok(img.thumbnail(width, height))
}