Express.js middleware to serve images in the dimension needed. 🖼
ffmpeg
needs to be installed on the host system.
npm i -S serve-image
const express = require('express');
const {serveImage} = require('serve-image');
const app = express();
app.use(serveImage());
app.listen(80);
Requesting localhost/path/to/image.png
will return the full image. Requesting localhost/path/to/image.png?size=50%
will return the image half the size of the original.
Query parameters that the middleware uses if set.
To resize the image on request. Accepts any kind of ffmpeg size that is provided (e.g. 50%
, 640x?
, 640x480
).
Middleware to request images in different sizes from a source directory. Accepts an object of options.
All options are optional.
The source directory to be used to search for the given image.
Optional error callback used by fluent-ffmpeg
.
Optional progress callback used by fluent-ffmpeg
.
Optional end callback used by fluent-ffmpeg
.
GPL-2.0 © Willi Eßer