https://github.com/alexferl/air
Asset storage and on-the-fly image resize
https://github.com/alexferl/air
go golang image-resizer libvips vips vips-image
Last synced: about 1 year ago
JSON representation
Asset storage and on-the-fly image resize
- Host: GitHub
- URL: https://github.com/alexferl/air
- Owner: alexferl
- License: mit
- Created: 2022-02-04T02:08:36.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-24T22:41:50.000Z (about 4 years ago)
- Last Synced: 2025-01-22T16:48:36.170Z (over 1 year ago)
- Topics: go, golang, image-resizer, libvips, vips, vips-image
- Language: Go
- Homepage:
- Size: 3.85 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# air - Asset & Image Resize
Asset storage and on-the-fly image resize powered by [libvips](https://github.com/libvips/libvips).
### Uploading an asset
```shell
$ http -f POST http://127.0.0.1:1323/upload file@cat.png
HTTP/1.1 201 Created
Access-Control-Allow-Origin: *
Content-Length: 78
Content-Type: application/json; charset=UTF-8
Date: Fri, 04 Feb 2022 02:31:54 GMT
Location: /assets/b056dab52b1ad845a72da28ab28bcc39948011ec68122ff791da252afdfcd67e
Vary: Origin
{
"id": "b056dab52b1ad845a72da28ab28bcc39948011ec68122ff791da252afdfcd67e"
}
```
### Retrieving an asset
Retrieve an asset in the format it was uploaded:
```shell
$ http http://127.0.0.1:1323/assets/b056dab52b1ad845a72da28ab28bcc39948011ec68122ff791da252afdfcd67e
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: image/png
Date: Fri, 04 Feb 2022 02:32:10 GMT
Transfer-Encoding: chunked
Vary: Origin
```
Retrieve an image asset in a different format:
```shell
$ http http://127.0.0.1:1323/assets/b056dab52b1ad845a72da28ab28bcc39948011ec68122ff791da252afdfcd67e?format=jpeg
Content-Type: image/jpeg
```
Valid formats are `jpeg`, `png` and `webp`.
Retrieve an image asset in a different size:
```shell
$ http http://127.0.0.1:1323/assets/b056dab52b1ad845a72da28ab28bcc39948011ec68122ff791da252afdfcd67e?size=640x480
```
Valid size parameters (max size: `5000`x`5000`):
```
size=640x480 # force size, that is, break aspect ratio
size=640 # will scale the height accordingly
width=640&height=480 # force size, that is, break aspect ratio
width=640 # will scale the height accordingly
height=480 # will scale the width accordingly
```
Retrieve an image asset in a different quality:
```shell
$ http http://127.0.0.1:1323/assets/b056dab52b1ad845a72da28ab28bcc39948011ec68122ff791da252afdfcd67e?quality=50
```
The quality must be between `1` and `100`.
## Development
Install libvips by following the instructions [here](https://github.com/davidbyttow/govips#dependencies).
### Installing dependencies
```shell
$ make dev
```
### Building and running
```shell
$ make run
```
### Running tests
```shell
$ make test
```