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

image-responsive-cache

v0.0.4

Published

Library to resize and cache images using presets of dimensions

Readme

image-responsive-cache

This is a library to resize and cache images using an arbitrary presets of dimensions.

If you are running Google Speed Insights test on your web pages and you notice that score is low because of images then you can probably do some optimization. Depending on your designs your desktop might call for a different resolution of images from mobile or tablet view. The closer the rendered image is to the actual dimensions of the image the better the score is going to be. You might want to serve different dimensions to different screen sizes so you might need a few presets.

This library is responsible for resizing and caching images at a defined cache path. You will need to setup your own routes that resolve to cached paths, however. For example in express or hapi you will want to initalize routes that resolve to cached images using

Requirements

This library works with ImageMagick or GraphicsMagick so it is required that one of these is installed.

Installation

npm i --save-responsive-cache

Usage

You

'use strict';

const irc = require('image-responsive-cache');

var ircObj = irc({
    extension: 'jpg',       // default is jpg
    quality: 75,            // this is the default
    debug: true,            // set false in production
    cache_path: '/tmp',     // cache image is created here
    presets: {              // you can have any number of presets or you can use default ones.
        PRESET1: {        // defined preset coming from you configs
            width: 200,     // width is 200
            height: null,   // height is auto. current aspect ratio is preserved
        },
        PRESET2: {
            width: 100,
            height: null
        }

    }
});

// resize and cache image
let cached = ircObj.image('PRESET1', __dirname + '/images/sample.jpg');
console.log("PRESET1 Image: ", cached);

let cached2 = ircObj.image('PRESET2', __dirname + '/images/sample.jpg');
console.log("PRESET2 Image: ", cached2);

Output:

image not in cache. resizing...
Directory /tmp/PRESET1 created!
Directory /tmp/PRESET1/b created!
Directory /tmp/PRESET1/b/1 created!
PRESET1 Image:  /tmp/PRESET1/b/1/b1f1d7e25a8deb66010a0c932fff4d02b6b505e5.jpg
image not in cache. resizing...
Directory /tmp/PRESET2 created!
Directory /tmp/PRESET2/b created!
Directory /tmp/PRESET2/b/1 created!
PRESET2 Image:  /tmp/PRESET2/b/1/b1f1d7e25a8deb66010a0c932fff4d02b6b505e5.jpg

Use cached and cached2 paths in your webserver routes.