Image resizing and caching proxy in front of S3
- TypeScript 84.1%
- C 13.1%
- Dockerfile 2.2%
- Shell 0.6%
| src | ||
| .dockerignore | ||
| .gitignore | ||
| bun.lock | ||
| docker-compose.yml | ||
| Dockerfile | ||
| entrypoint.sh | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
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 /imageget 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 inx,y, assumes center?fmt=convert image to format?rawreturn raw source image