Express middleware for on-the-fly image processing based on query string parameters. Version 11.2.0. Intended for development use, not production. Supports multiple image formats (PNG, JPG, GIF, SVG) and operations (resize, pngcrush, optipng, jpegtran, svgfilter, etc.). Uses impro module to switch between backends (GraphicsMagick, ImageMagick, command-line tools). Alternative to separate build tools. Note: due to shelling out to external binaries, it presents security concerns; validate inputs and limit image sizes in production.
npm install express-processimageVerified import paths — ran on the pinned version, not inferred.
Set up Express server with express-processimage middleware to serve processed images via query parameters.
Use const app = express(); app.use(processImage({root})); app.listen(1337);Always pass { root: '/path' } object.Order: app.use(processImage({root})), then app.use(express.static(root)).Use 'pngcrush' instead of 'optipng'.
Upgrade Node.js to v10 or higher.
Set cache-control headers explicitly.
Install optipng via package manager (e.g., apt-get install optipng).
Use const processImage = require('express-processimage') or import processImage from 'express-processimage'.Run npm install express-processimage to install all dependencies.
Add { root: '/path/to/images' } to processImage options.