air

command module
v0.0.0-...-d11079c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2022 License: MIT Imports: 14 Imported by: 0

README

air - Asset & Image Resize

Asset storage and on-the-fly image resize powered by libvips.

Uploading an asset
$ http -f POST http://127.0.0.1:1323/upload [email protected]
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:

$ 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:

$ 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:

$ http http://127.0.0.1:1323/assets/b056dab52b1ad845a72da28ab28bcc39948011ec68122ff791da252afdfcd67e?size=640x480

Valid size parameters (max size: 5000x5000):

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:

$ 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.

Installing dependencies
$ make dev
Building and running
$ make run
Running tests
$ make test

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL