woogiee / sharp-image-proxy

:airplane: An on the fly image optimization microservice

Home Page:https://adamlacombe.com/blog/how-to-convert-images-to-avif-in-nodejs?utm_source=github&utm_medium=repo_description

Repository from Github https://github.comwoogiee/sharp-image-proxyRepository from Github https://github.comwoogiee/sharp-image-proxy

sharp-image-proxy

An on the fly image optimization microservice.

I'm using this to dynamically resize, compress and serve images on my blog.

It's hosted on Google Cloud Run behind Cloudflare with the following page rule settings:

Screenshot from 2020-09-09 19-18-19

Run using Docker

docker run \
  -it --rm \
  -p 8080:8080 \
  --name sharp-image-proxy \
  docker.pkg.github.com/adamlacombe/sharp-image-proxy/sharp-image-proxy:latest

Features

  • Resize images proportionally.
  • Support for webp, avif, png, jpeg and tiff.

Options

  • url
  • width
  • height
  • format = webp | avif | png | jpeg | tiff
  • quality = 1 - 100 (default 80)

Example requests

  • /?url=https://via.placeholder.com/500&width=300
  • /?url=https://via.placeholder.com/500&width=300&format=webp
  • /?url=https://via.placeholder.com/500&width=300&format=webp&quality=50
  • /?url=https://via.placeholder.com/500&width=300&format=avif&quality=30

Run on Google Cloud

About

:airplane: An on the fly image optimization microservice

https://adamlacombe.com/blog/how-to-convert-images-to-avif-in-nodejs?utm_source=github&utm_medium=repo_description

License:MIT License


Languages

Language:TypeScript 96.3%Language:Dockerfile 3.7%