ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - Pixboost/transformimgs: Open source image CDN.
Open source image CDN. Contribute to Pixboost/transformimgs development by creating an account on GitHub.
Visit Site

GitHub - Pixboost/transformimgs: Open source image CDN.

GitHub - Pixboost/transformimgs: Open source image CDN.

TransformImgs

Go Reference Go Report Card 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, Jpeg XL, and network client hints.

Table of Contents

Why?

We wrote a big blog on this, and here is TLDR:

Transformimgs is an image CDN for Web, so API must cover typical use cases, like thumbnails, zoom in product images, etc. Any new API endpoints must solve the above problems.

The goal is to have zero-config API that makes decisions based on the input, so you don't need to provide additional parameters like quality, output format, type of compression, etc.

Therefore, this allows you to configure the integration once. New features, like new image formats, will work with your front end automatically without any changes.

To achieve that goal we should keep API to bare minimum and hide the smartness in the implementation.

Features

  • Resize/optimises/crops raster (PNG and JPEG) images.
  • JpegXL / AVIF / WebP support based on "Accept" header.
  • Vary header support - ready to deploy behind any CDN.
  • Responsive images support including high DPI (retina) displays
  • Save-Data support

Quickstart

There is an example of running API behind reverse proxy with integration example in quickstart/ folder.

To run:

cd quickstart
docker-compose up
open https://localhost

API

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

Docs:

  • Swagger-UI - use API key MjUyMTM3OTQyNw__ which allows to transform any image from unsplash.com
  • OpenAPI spec

Running Locally

Docker

The latest docker image published on Docker hub

Starting the server:

$ docker run -p 8080:8080 pixboost/transformimgs [OPTIONS]

To verify:

  • Health check: curl http://localhost:8080/health
  • Transformation: open http://localhost:8080/img/https://images.unsplash.com/photo-1591769225440-811ad7d6eab3/resize?size=600

Options

Everything below is optional and have sensible defaults.

Option Description Default
cache Number of seconds to cache image(0 to disable cache). Used in max-age HTTP response. 2592000 (30 days)
proc Number of images processors to run. Number of CPUs (cores)
disableSaveData If set to true then will disable Save-Data client hint. Should be disabled on CDNs that don't support Save-Data header in Vary. false

Running from source code

Prerequisites:

Install illustration command:

cd illustration/
go install

Run the application:

./run.sh 

Using from Go Web Application

You could also easily plugin HTTP route into your existing web application using service.GetRouter method. Here is a quick example of how to do that.

SaaS

We run SaaS version at pixboost.com with generous free tier.

Perks of SaaS version:

  • CDN with HTTP/3 support included
  • Dashboard with usage monitor
  • API Key support with domains allow list
  • AWS S3 integration
  • API workflows for cache busting and warmup
  • Version upgrades

Go modules have been introduced in v6.

Performance tests

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
  • Run JMeter tests:
$ 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
  • Run JMeter JPEG XL test:
$ jmeter -n -t perf-test-jxl.jmx -l ./results-jxl.jmx -e -o ./results-jxl

Opened tickets for images related features

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
  • JpegXL Support since supported by Safari 17 (Added in version 8.12.0)
  • GIF support (Added in version 6.1.0)

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory