Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
cmd
 
 
img
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

TransformImgs

Build Status Docker Automated build

Image transformations web service. Provides Http API to image manipulation operations backed by Imagemagick CLI.

Table of Contents

Features

  • Resize/optimises/crops raster (PNG and JPEG) images.
  • AVIF/WebP support based on "Accept" header.
  • Sets "Cache-Control" header in a response. Cache TTL is configurable through command line flag "-cache".
  • Execution queue that will create number of executors based on number of CPUs or can be configured through "-proc" flag.
  • Supports "Vary" header to cache responses based on the output format.

Install

Using docker:

$ docker pull pixboost/transformimgs

Usage

$ docker run -p 8080:8080 pixboost/transformimgs

To test that application started successfully:

$ curl http://localhost:8080/health

You should get 'OK' string in the response.

At the moment application provides 4 HTTP endpoints:

  • /img/{IMG_URL}/optimise - optimises image
  • /img/{IMG_URL}/resize - resizes image
  • /img/{IMG_URL}/fit - resize image to the exact size by resizing and cropping it
  • /img/{IMG_URL}/asis - returns original image

Detailed API docs are here - https://pixboost.com/docs/api/

Running the application locally from sources

$ docker-compose up

Building and Running from sources

Dependencies:

$ go get github.com/golang/dep/cmd/dep
$ go get github.com/Pixboost/transformimgs
$ cd $GOPATH/src/github.com/Pixboost/transformimgs
$ ./run.sh 

Performance tests

There is a JMeter performance test you can run against a service. To run tests:

  • Run performance test environment:
$ docker-compose -f docker-compose-perf.yml up
  • Run JMeter test:
$ jmeter -n -t perf-test.jmx -l ./results.jmx -e -o ./results
  • Run JMeter WebP test:
$ jmeter -n -t perf-test-webp.jmx -l ./results-webp.jmx -e -o ./results-webp
  • Run JMeter AVIF test:
$ jmeter -n -t perf-test-avif.jmx -l ./results-avif.jmx -e -o ./results-avif

API

You can go through API docs and try it out there as well. Use API key MTg4MjMxMzM3MA__ to transform any images from pixabay.com.

Go-swagger is used to generate swagger.json file from sources. To generate:

$ go get -u github.com/go-swagger/go-swagger/cmd/swagger
$ cd cmd/
$ swagger generate spec -o ../swagger.json

Contribute

Shout out with any ideas. PRs are more than welcome.

License

MIT

Todo

  • Add JpegXR support (IE supports WEBP)
  • Add Jpeg 2000 support (Safari support WEBP)
  • Client Hints
  • Save-Data header
  • SVG support
  • Consider using Zopfli or Brotli for PNGs
  • GIF support
You can’t perform that action at this time.