Resize and Optimize image on-the-fly for your website
291
Resize and Optimize image on-the-fly
Node-alpine service to transform images from another service on the fly (s3, google cloud storage, ...)
Use the following libraries:
imgresizer:
image: kefniark/image-resizer
environment:
# the host of original images
- STORAGE_HOST=https://your.website.com/
# cache in minutes
- CACHE=300
# server port
- PORT=80
ports:
- 80:80
or if you want to run it locally in node, put your env variables in a .env file then run
yarn
yarn dev
Url: http://localhost:8000/images/subfolder/image.jpg?width=100&height=100
http://localhost:8000/images/subfolder/image.jpg => will be resolved to https://your.website.com/images/subfolder/image.jpg?width=100&height=100width: number in the range 10 <> 2048height: number in the range 10 <> 2048fit: 'cover' | 'contain' | 'fill' | 'inside' | 'outside'blur: number in the range 0.3 <> 1000rotate: number in the range -360 <> 360grey: booleannormalize: booleanformat: 'jpg' | 'png' | 'webp'quality: number in the range 1 <> 100?format=jpg?format=webp&quality=5?height=200&format=webp?width=200&height=200&format=webp&fit=contain?width=640&height=360&format=webp&blur=9yarn lint
yarn test
yarn build
docker build -t kefniark/image-resizer:latest .
docker push kefniark/image-resizer:latest
Content type
Image
Digest
Size
48.9 MB
Last updated
over 4 years ago
docker pull kefniark/image-resizer