https://github.com/monder/wain
Image resizing proxy
https://github.com/monder/wain
Last synced: about 2 months ago
JSON representation
Image resizing proxy
- Host: GitHub
- URL: https://github.com/monder/wain
- Owner: monder
- License: mit
- Created: 2016-06-24T20:03:15.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-07-17T11:35:57.000Z (almost 9 years ago)
- Last Synced: 2025-02-13T15:18:12.410Z (4 months ago)
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Wain
[](https://goreportcard.com/report/github.com/monder/wain)
[]()
[]()Wain is a http proxy that allows to dynamically resize and serve images from an s3 bucket.
## Installation
### Installing libvips on MacOS
```
brew install homebrew/science/vips --with-mozjpeg
```## Docker image
```
docker run -v /home/user/config.yaml:/config.yaml -p 3000:3000 monder/wain /config.yaml
```## Configuration
Wain allows to configure routes in `yaml` format.
```yaml
# vim: ts=2:sw=2
port: 3000
buckets:
- name: wain-demo-content
region: eu-west-1
accessKey: AKIAJMK6JWZF4F4JBSXQ
accessSecret: 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
urls:
- pattern: /images/{id:IMG_\d+}/{width:[0-9]+}{height:(x[0-9]+)?}.jpg
original:
bucket: wain-demo-content
key: original/{id}.JPG
cache:
bucket: wain-demo-content
key: cache/{id}/{width}{height}.jpg
```The configuration above will process the urls only matching the pattern `/images/{id:IMG_\d+}/{width:[0-9]+}{height:(x[0-9]+)?}.jpg` capturing the variables.
Note thate the `height` parameter is optional (`?`) and the pattern will match both:
`/images/IMG_2530/100.jpg`
and
`/images/IMG_2530/100x150.jpg`The file will be downloaded from the bucket specified in `original`. `bucket` name is looked up in `buckets` section. `key` should be the file name inside the bucket. All variables captured in `pattern` could be used here to generate the key. All unknown variables are replaced with an empty string (`""`).
Requesting the file `/images/IMG_2530/100.jpg` will download and resize file `wain-demo-content/original/IMG_2530.JPG` to width `100px` and some height keeping the aspect ratio of the original.
`100`:
Specifying the `height` as well as `width` will fit the original, adding a blurred background:
`100x150`:
`150x100`:
