Skip to content

Commit

Permalink
Add configuration example to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
pohlm01 committed Oct 30, 2023
1 parent 7e6ac4b commit cfdea83
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,34 @@ Easy-to-use library to create image thumbnails from images existing on some (clo
Currently implemented is a connection to Google Cloud Storage, but it can be easily extended to other providers.

# How to use
Configure what thumbnails you would like to have:
```yaml
thumbs:
- name: standard # this name will be added to the thumbnail with an underscore (_)
quality: 80 # PNG ignores this variable as it is always lossless
size: [ 640, 480 ] # Target size of the thumbnail. May not always be exact.
mode: fit # available are: 'fit' and 'crop'

```rust
- name: mini
quality: 80
size: [ 40, 40 ]
mode: crop
```
Then use it in your code
```rust
#[tokio::main]
async fn main() {
let thumbs = image_thumbs::ImageThumbs::new("examples/image_thumbs")
.await
.unwrap();
thumbs
.create_thumbs("penguin.jpg", "/thumbs", false)
.create_thumbs("penguin.jpg", "/thumbs", false) // do not override existing images
.await
.unwrap();
thumbs
.create_thumbs("penguin.png", "/thumbs", false)
.create_thumbs("penguin.png", "/thumbs", true) // do override existing images
.await
.unwrap();
}
```
```

0 comments on commit cfdea83

Please sign in to comment.