Project based on Imgproxy for serving a static files, these files can be resized and optimized by url request
The idea is to have a image media server, and server to provide different images sizes, also they can cached the images has been resized for optimize the performance
To upload the image files you must provide it manually (via ftp or own development)
Example:
This example is resized to 300 x 168 (ratio 16x9) + converted to webp + reduced quality + added background white if original image don't have same ratio
-
In the case that you provide information in the url query with
?the program will optimize the image according to the data sent and will automatically cache the image in the .cache folder, so the next request will not have to process it -
In the event that you do not provide data in the query, it will send the original size directly
A bunch of parameters are based from original program Imgproxy and not all parameters are included in this program
Current parameters included:
- format
png | jpg | webp | avif | gif | ico | bmp | tiff|default: jpg - resizing_type
fit | fill | fill-down | force | auto|default: fit - width
- height
defaut: Is is not setted the image is preserve the original ratio - quality
default: 75 - enlarge
default: 0 - extend
default: 0 - background_rgb
default: FFFFFF
Now you can use Aws S3 to store images and this can make a proxy to resize and optimize the images
To use it only need to add enviorement variables:
USE_AWS_S3=true
AWS_REGION=us-east-1
AWS_BUCKET_NAME=your-bucket-name
AWS_ACCESS_KEY_ID=your-access-key-id
AWS_SECRET_ACCESS_KEY=your-secret-access-keyDocker is required because Imgproxy are used via docker to compress the files
- Copy example docker compose:
curl -o docker-compose.yml https://raw.githubusercontent.com/sefirosweb/Imgproxy-With-Cache/master/production/docker-compose.yml - Create and edit
.envfile, you need to set the port and app_url - Start docker compose:
docker-compose -up -d
Docker is required because Imgproxy are used via docker to compress the files
- Create and edit .env file, you need to set the port and app_url
- Start containers:
docker-compose up -d - Login to node container:
docker-compose exec -u node app_imgproxy bash - Install dependencies:
npm install - Start development:
npm run dev - On finish test the build operation:
npm run build - Start server:
npm start
You can debug with vscode, default port to listen: 9229
- docker build -f docker/Dockerfile -t sefirosweb/imgproxywithcache:latest .
- docker tag sefirosweb/imgproxywithcache:latest sefirosweb/imgproxywithcache:1.1.0
- docker push sefirosweb/imgproxywithcache:latest
- Add batch to compress and cache the files
- Add search input to find the images or folder
- Improve to Vue instead EJS

