npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

thumb-cutter

v1.1.1

Published

On-the-fly image manipulation middleware for express.js

Readme

Thumb Cutter

Thumb Cutter slices your images with blazing speed (with the help of sharp library)! It comes as express.js middleware, so you can just plug it in and start using by adding query parameters onto a standard image url. It's ideal for web developers who would like to easily experiment with different thumbnail sizes generated on the go.

You can throw at it JPEG, PNG and WebP images. Colour spaces, embedded ICC profiles and alpha transparency channels are all handled correctly.

Since Thumb Cutter is using libvips image processing library we're in for some benefits straight from Birkbeck College!

Quoting from sharp's README:

Only small regions of uncompressed image data are held in memory and processed at a time, taking full advantage of multiple CPU cores and L1/L2/L3 cache. Resizing an image is typically 4x faster than using the quickest ImageMagick and GraphicsMagick settings.

Huffman tables are optimised when generating JPEG output images without having to use separate command line tools like jpegoptim and jpegtran. PNG filtering can be disabled, which for diagrams and line art often produces the same result as pngcrush.

Everything remains non-blocking thanks to libuv, no child processes are spawned and Promises/A+ are supported.

Usage

var express = require('express'),
    app = express(),
    thumbCutter = require('thumb-cutter');

app.use('/pictures', thumbCutter.static(__dirname + '/../pictures'));
<img src="/pictures/bw/photo.jpg?dim=200x100&amp;rotate=true" alt="" />

Install

npm install thumb-cutter

libvips is required for this module, so make sure it is installed.

Debian

apt-get install libvips libvips-dev libgsf-1-dev

Mac OS X

brew install vips

Documentation

thumbCutter.static(path, [options])

Middleware to replace express.static() or connect.static().

path is the base directory where images are located.

options is an object to specify customizations. It currently has the following options:

  • cacheDir The directory where generated images will be created. (default: [path]/.cache/)
  • quality The output quality to use for lossy JPEG, WebP and TIFF output formats. (default: 80)
  • rotate Rotate the output image by either an explicit angle or auto-orient based on the EXIF Orientation tag. (default: false)
  • progressive Use progressive (interlace) scan for JPEG and PNG output. (default: true)
  • withMetadata Include all metadata (EXIF, XMP, IPTC) from the input image in the output image. This will also convert to and add the latest web-friendly v2 sRGB ICC profile. (default: false)
  • setHeaders Callback with signature function(res, filepath), called before res.sendFile(filepath)

Resizing of images is directed by the query parameter dim. This is in the format [width]x[height]. E.g. red.gif?dim=200x100

Resized images will be created on an as needed basis, and stored in cacheDir.

If there is no parameters present, the original image will be served.

thumbCutter.convert(options, callback)

The first argument is an options object. callback argument is required.

  • src (required) Path to source image
  • dst (required) Path to destination image
  • width Width of resized image
  • height Height of resized image
  • quality The output quality to use for lossy JPEG, WebP and TIFF output formats.
  • rotate Rotate the output image by either an explicit angle or auto-orient based on the EXIF Orientation tag.
  • progressive Use progressive (interlace) scan for JPEG and PNG output.
  • withMetadata Include all metadata (EXIF, XMP, IPTC) from the input image in the output image. This will also convert to and add the latest web-friendly v2 sRGB ICC profile.

The callback argument gets 2 arguments. The first is an error object, most likely from sharp. The second argument is the path to the created image.