https://github.com/0xtlt/express-images
resize and crop your images just with a link
https://github.com/0xtlt/express-images
Last synced: 2 months ago
JSON representation
resize and crop your images just with a link
- Host: GitHub
- URL: https://github.com/0xtlt/express-images
- Owner: 0xtlt
- License: mit
- Created: 2020-08-29T20:24:46.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-30T08:51:38.000Z (almost 6 years ago)
- Last Synced: 2026-01-26T17:53:04.659Z (5 months ago)
- Language: JavaScript
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Express Images 🏙
Resize and crop your pictures directly with a link
## Installation 📌
`$ npm install express-images`
## Usage
```javascript
const express = require('express');
const expressImage = require('express-images');
const app = express();
expressImage(app, {
folder: __dirname + '/images', // the images folder
path: '/media', // the handle
cache: __dirname + '/.cacheImages', // Store generated images
maxWidth: 1920,
maxHeight: 1920,
quality: 90, // image quality, 90 is perfect, 100 can be heavy
expiration: 10000, // in ms | can be set as false (optional : default false)
expirationInterval: 1500, // in ms (optional : default 1000)
});
// your code...
```
You must add the `__dirname` variable for the cache path and the folder path
Just `folder`, `path` and `cache` settings are required
## Handle usage
To resize your image you can add : `_{width}x{height}` before your file extension like :
`cat_500x500.jpg`
Height can be not defined -> `cat_500x.jpg`
You can resize and crop your image : `_{width}x{height}x{cropHorizontaly}x{cropVerticaly}`
`cropHorizontaly` values are : `center` (default), `left` and `right`
`cropVerticaly` values are : `center` (default), `top` and `bottom`
`cropHorizontaly` or/and `cropVerticaly` values can be not defined
examples :
`cat_500x500xcenter.jpg`, `cat_500x500xcenterxbottom.jpg`, `cat_500x500xxcenter.jpg`