diff --git a/.gitignore b/.gitignore index 96ef6c0..408b8a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target Cargo.lock +.idea \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/discord.xml b/.idea/discord.xml deleted file mode 100644 index 30bab2a..0000000 --- a/.idea/discord.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index cb3dd20..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/thumbnailer.iml b/.idea/thumbnailer.iml deleted file mode 100644 index 457e3e6..0000000 --- a/.idea/thumbnailer.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index e3a2c52..05cd0fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,9 @@ [package] name = "thumbnailer" +readme = "README.md" +license = "Apache-2.0" +authors = ["trivernis "] +description = "An image thumbnail creation library" version = "0.1.0" edition = "2018" diff --git a/README.md b/README.md new file mode 100644 index 0000000..8ec93df --- /dev/null +++ b/README.md @@ -0,0 +1,35 @@ +# Thumbnailer + +This crate can be used to create thumbnails for all kinds of files. + +## Usage + +```rust +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 \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index c6ba972..ab7ef9d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,24 @@ +//! # 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; +//! +//! 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(); +//! } +//! ``` + use crate::error::ThumbResult; use image; use image::imageops::FilterType;