Open Source Image CDN that provides image transformation API and supports
the latest image formats, such as WebP, AVIF and network client hints.
There are two ways of using the service:
- Deploy on your own infrastructure using docker image
- Use as SaaS at pixboost.com
Perks of SaaS version:
- CDN with HTTP/3 support included
- Dashboard with usage monitor
- API Key support with domains allow list
- AWS S3 integration
- Elastic scaling based on load
- Upgrades + Support
Table of Contents
Features
- Resize/optimises/crops raster (PNG and JPEG) images.
- AVIF/WebP support based on "Accept" header.
- Could be deployed behind CDN - sets "Vary" header to cache responses with the same URL.
- 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.
Install
Using docker:
$ docker pull pixboost/transformimgs
Usage
$ docker run -p 8080:8080 pixboost/transformimgs [OPTIONS]
To test that application started successfully:
$ curl http://localhost:8080/health
You should get 'OK' string in the response.
The API has 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 Documentation
-
Markdown API docs
Options
Option |
Description |
cache |
Number of seconds to cache image after transformation (0 to disable cache). Default value is 86400 (one day) |
proc |
Number of images processors to run. Defaults to number of CPUs |
disableSaveData |
If set to true then will disable Save-Data client hint. Could be useful for CDNs that don't support Save-Data header in Vary. |
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.
There is a JMeter performance test you can run against a service. To run tests:
- Start a performance test environment:
$ docker-compose -f docker-compose-perf.yml up
$ jmeter -n -t perf-test.jmx -l ./results.jmx -e -o ./results
$ jmeter -n -t perf-test-webp.jmx -l ./results-webp.jmx -e -o ./results-webp
$ 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__
which allows to transform any images from pixabay.com.
Go-swagger is used to generate swagger.json schema file from sources.
To generate schema and api.md:
- Install version 0.26.1
./generate-api-docs.sh
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 - on hold due to browsers adoption
Save-Data header (Added in version 7.0.0)
- SVG support
- Consider using Zopfli or Brotli for PNGs
GIF support (Added in version 6.1.0)