Skip to content

Go image scaling microservice example with bimg

License

Notifications You must be signed in to change notification settings

codesoap/bimg-rest

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Image Scaling Microservice Example with bimg

Example implementation of a REST microservice based on bimg, a very fast image processing library which uses native library libvips via C bindings.

Build & Launch

Besides Go 1.16, libvips needs to be installed separately. bimg apparently works with libvips 8.3, but recommends 8.8+.

Locally

Follow installation instructions for libvips, e.g.

$ apt install libvips

Run the application at port 8080:

$ cd src
$ go run .

With Docker

$ docker build --pull --rm -t bimg-rest-example:latest .
$ docker run --rm -it  -p 8080:8080/tcp bimg-rest-example:latest

With docker-compose

$ docker-compose up

Usage

Send a multipart/form-data request with a single file named image to the /scale endpoint. Width and height of the target image is set via the URL query parameters width and height respectively. Optionally, image output format can be specified (jpeg, png, gif, webp, heif, or avif)

$ curl -F image=@/path/to/in.png -o /path/to/out.png http://localhost:8080/scale?width=200&height=200&format=png

Alternatively, there is also test.html with HTML form and input. While experimenting, just edit the form action URL.

See Also

About

Go image scaling microservice example with bimg

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 78.7%
  • Dockerfile 13.0%
  • HTML 8.3%