node-imgoptimize
v0.4.5
Published
Proxy server for image optimization on Node.JS use (fastify, axios, sharp)
Downloads
12
Maintainers
Readme
node-imgoptimize
Proxy server for image optimization on Node.JS use (fastify, axios, sharp) Automatic recognition of browser support formats WebP
Install
Yarn
yarn add node-imgoptimize
git clone https://github.com/AntonLukichev/node-imgoptimize.git
yarn install
NPM
npm install node-imgoptimize --save
git clone https://github.com/AntonLukichev/node-imgoptimize.git
npm install
Requires node >= 8.0, but I recommended use >= 10.0 LTS
Heroku
example https://node-imgoptimize.herokuapp.com/
use Docker
$ git clone https://github.com/AntonLukichev/node-imgoptimize.git
$ cd ./node-imgoptimize
$ docker build -t node-imgoptimize .
$ docker run -it --rm -p 3000:3000 -e NODE_ENV=production node-imgoptimize
$ git clone https://github.com/AntonLukichev/node-imgoptimize.git
$ cd ./node-imgoptimize
$ docker-compose build
$ docker-compose up
see tips for Docker
Example Usage
{url}?w=500&q=80
support parameters (after "?"):
w - image width; h - image height; q - image quality, 80 recommended for JPEG and WebP; fm - image format, list in config.js and default jpeg or webp (if browser supports it);
Example config
Edit defaults config for you need (automatically created after the first run)
./config/config.js
./config/server.js
ToDo
v0.2.0:
- [x] generate source url with original request parameters
- [x] caching original file
- [x] support a large number of files
v0.3.0:
- [x] add multiple path URI
- [x] add JPEG and WebP options
v0.4.0:
- [x] custom log level
- [x] documentation API in Swagger
- [x] add docker
- [x] support Heroku
v0.5.0:
- [x] add monitoring errors sentry.io
- [x] default favicon
- [ ] add tests
I plan to implement in the future:
- expand API
- add options Low Quality Image Placeholders (LQIP)
- add Client Hints (headers DPR, Viewport-Width, Width) for support Chrome, Opera, Android Chrome
- add support another formats (GIF, PNG, SVG...)
- divide the functionality into modules up to version 1.0.0
- support PAAS (~~Heroku~~, Zeit, Nanobox...)
- add support HTTP2
- add security protection
- add support redis/mongo for cache info
- add image operations (rotate, blur, normalise...)
Lazy loading
If you'd like to lazy load images, I recommend using lazysizes.
FAQ
How add custom favicon
Simple copy your favicon.ico file in root directory project
Security
Production Best Practices: Security
Contributing
See the CONTRIBUTING file here
License
Copyright (c) Anton Lukichev