From 5017e269913375336caa26d88f95aea859033008 Mon Sep 17 00:00:00 2001 From: trivernis Date: Sat, 29 Jan 2022 15:23:55 +0100 Subject: [PATCH] Add function to get the size of a thumbnail Signed-off-by: trivernis --- Cargo.toml | 2 +- src/lib.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 14437ab..de75089 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ readme = "README.md" license = "Apache-2.0" authors = ["trivernis "] description = "An image thumbnail creation library" -version = "0.2.4" +version = "0.2.5" edition = "2018" repository = "https://github.com/Trivernis/thumbnailer" diff --git a/src/lib.rs b/src/lib.rs index d723e1b..891ad4f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,7 +22,7 @@ use crate::error::ThumbResult; use image; use image::imageops::FilterType; -use image::{DynamicImage, ImageOutputFormat}; +use image::{DynamicImage, GenericImageView, ImageOutputFormat}; use mime::Mime; use rayon::prelude::*; use std::io::{BufRead, Seek, Write}; @@ -55,6 +55,11 @@ impl Thumbnail { Ok(()) } + + /// Returns the size of the thumbnail as width, height + pub fn size(&self) -> (u32, u32) { + self.inner.dimensions() + } } /// Creates thumbnails of the requested sizes for the given reader providing the content as bytes and