Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including express-processimage with all npm packages installed. Try it out:

var expressProcessimage = require("express-processimage")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

express-processimage v7.9.0

Express middleware that processes served images according to the query string


NPM version Build Status Coverage Status Dependency Status

Middleware that processes images according to the query string. Intended to be used in a development setting with the connect.static middleware, but should work with any middleware further down the stack, even an http proxy.

Important note: This module is intended for development. You're strongly discouraged from using it in production or with any kind of untrusted input. Parts of the query string will be passed directly to various command line tools.

The response will be be processed under these circumstances:

  • If the request has a query string and accepts image/*.
  • If the response is served with a Content-Type of image/*.

express-processimage plays nice with conditional GET. If the original response has an ETag, express-processimage will add to it so the ETag of the processed image never clashes with the original ETag. That prevents the middleware issuing the original response from being confused into sending a false positive 304 Not Modified if express-processimage is turned off or removed from the stack later.

Query string syntax

express-processimage supports pngcrush, pngquant, optipng, jpegtran, inkscape, svgfilter, and all methods listed under "manipulation" and "drawing primitives" in the documentation for the gm module.

Multiple tools can be applied to the same image (separated by &, and the order is significant). Arguments for the individual tools are separated by non-URL encoded comma or plus.



Make sure you have node.js and npm installed, then run:

npm install express-processimage

Example usage

Express 3.0 syntax:

var express = require('express'),
    processImage = require('express-processimage'),
    root = '/path/to/my/static/files';

    .use(processImage({root: root}))

The root option is used by node-svgfilter for finding the location of external JavaScript files to run on the SVG document.


3-clause BSD license -- see the LICENSE file for details.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free