transformimgs

module
v6.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: MIT

README

TransformImgs

Build Status codecov Docker Pulls Docker Automated build

Open Source Image CDN that provides image transformation API and supports the latest image formats, such as WebP, AVIF.

There are two ways of using the service:

  • Deploy on your own infrastructure using docker image
  • Use as SaaS at pixboost.com

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

Prerequisites:

$ git clone git@github.com:Pixboost/transformimgs.git
$ cd transformimgs
$ ./run.sh 

Go modules have been introduced in v6.

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 (Added in version 6.1.0)

Directories

Path Synopsis
Images transformations API The purpose of this API is to provide a set of endpoints that will transform and optimise images.
Images transformations API The purpose of this API is to provide a set of endpoints that will transform and optimise images.
img

Jump to

Keyboard shortcuts

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