11 releases

0.5.1 Jul 14, 2023
0.5.0 Jul 14, 2023
0.4.0 Feb 19, 2022
0.3.0 Feb 3, 2022
0.1.0 Nov 6, 2021

#441 in Images

Download history 24/week @ 2024-06-16 121/week @ 2024-06-23 85/week @ 2024-06-30 18/week @ 2024-07-07 21/week @ 2024-07-14 13/week @ 2024-07-21 24/week @ 2024-07-28 11/week @ 2024-08-04 14/week @ 2024-08-11 8/week @ 2024-08-18 14/week @ 2024-08-25 195/week @ 2024-09-01 373/week @ 2024-09-08 361/week @ 2024-09-15 716/week @ 2024-09-22 587/week @ 2024-09-29

2,044 downloads per month
Used in 2 crates

Apache-2.0

600KB
253 lines

Thumbnailer

This crate can be used to create thumbnails for all kinds of files.

Usage

use thumbnailer::{create_thumbnails, Thumbnail, ThumbnailSize};
use std::fs::File;
use std::io::BufReader;

fn main() {
    let file = File::open("tests/assets/test.png").unwrap();
    let reader = BufReader::new(file);
    let mut  thumbnails = create_thumbnails(reader, mime::IMAGE_PNG, [ThumbnailSize::Small, ThumbnailSize::Medium]).unwrap();
    
    let thumbnail = thumbnails.pop().unwrap();
    let mut buf = Vec::new();
    thumbnail.write_png(&mut buf).unwrap();
}

Supported media types

Type Subtype
Image Png
Image Bmp
image Jpeg
Image Webp
Image Gif

License

MIT


lib.rs:

Thumbnailer

This crate can be used to generate thumbnails for all kinds of files.

Example:

use thumbnailer::{create_thumbnails, Thumbnail, ThumbnailSize};
use std::fs::File;
use std::io::BufReader;
use std::io::Cursor;

fn main() {
    let file = File::open("tests/assets/test.png").unwrap();
    let reader = BufReader::new(file);
    let mut  thumbnails = create_thumbnails(reader, mime::IMAGE_PNG, [ThumbnailSize::Small, ThumbnailSize::Medium]).unwrap();
    
    let thumbnail = thumbnails.pop().unwrap();
    let mut buf = Cursor::new(Vec::new());
    thumbnail.write_png(&mut buf).unwrap();
}

Dependencies

~14–23MB
~273K SLoC