Image resizing and caching proxy in front of S3
  • TypeScript 84.1%
  • C 13.1%
  • Dockerfile 2.2%
  • Shell 0.6%
Find a file
2026-03-03 19:43:31 -07:00
src Support spaces 2026-03-03 19:43:31 -07:00
.dockerignore Initial commit 2026-03-03 18:33:28 -07:00
.gitignore Initial commit 2026-03-03 18:33:28 -07:00
bun.lock Initial commit 2026-03-03 18:33:28 -07:00
docker-compose.yml Initial commit 2026-03-03 18:33:28 -07:00
Dockerfile Fix permissions 2026-03-03 19:30:46 -07:00
entrypoint.sh Fix permissions 2026-03-03 19:30:46 -07:00
package.json Initial commit 2026-03-03 18:33:28 -07:00
README.md Initial commit 2026-03-03 18:33:28 -07:00
tsconfig.json Initial commit 2026-03-03 18:33:28 -07:00

img.cns.io

An API for caching, resizing, converting, and mutating images from my personal S3 buckets.

Running

To run the tool you must first set environment variables to provide credentials and to register sources. IMG looks for IMG_* environment variables which are "namespaced" based on the source name; IMG_HOME_* are environment variables which relate to the home namespace and will describe connection strings, default settings, etc. for img.cns.io/home.

Environment Variables

This table describes global configuration

Env Var Description Default Value
CACHE_PATH Location of image data cache /tmp/img
CACHE_MAX_MB Max disk cache size in MB 2048
VIPS_CONCURRENCY Max concurrent vips operations 4
MAX_SOURCE_MB Max S3 object size to download (MB) 100

For this table NS takes the place of the namespace. Multiple namespaces can be defined.

Env Var Description Default Value
IMG_NS_S3_HOST Host for S3-compatible API
IMG_NS_S3_BUCKET Bucket name which holds images
IMG_NS_S3_PATH Path prefix for accessing files in the bucket /
IMG_NS_S3_ACCESS_KEY_ID S3 Access Key
IMG_NS_S3_SECRET_ACCESS_KEY S3 Secret Key
IMG_NS_DEFAULT_FORMAT Default format to serve images in jpg
IMG_NS_DEFAULT_MAX_DIMS Default maximum image size to serve (resizes larger images to) 1920x1080

API

  • GET /image get the image in default format and up to max dimensions
    • ?w= resize image to maximum width
    • ?h= resize image to maximum height
    • ?z= resize center in x,y, assumes center
    • ?fmt= convert image to format
    • ?raw return raw source image