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

hoodie-plugin-imagine

v0.3.7

Published

Hoodie plugin for handling images

Readme

Imagine

Imagine is a hoodie plugin for handling image uploads. This is a functional but very early version so there might be some changes in the future.

features

  • resizes images client-side to reduce traffic and server processing time
  • create image groups and types to manage images
  • automated cropping & resizing
  • jpg & png images supported
  • define different filters (uses GraphicsMagick)
    • sepia
    • monochrome
    • blur 30, 20
    • colorize 100, 0, 0
    • modulate 100, 50

API

All methods except .get are returning promises. Also .add, .update and .upsert call a progress as soon as an image is resized client-side.

// uploads an image and returns a image object
hoodie.imagine.upsert(group, dataUrlOrUrl);

hoodie.imagine.add(group, dataUrlOrUrl);
hoodie.imagine.update(id, group, dataUrlOrUrl);

// find an image by an id or an array of ids, returns an image object
hoodie.imagine.get(id);

// find images of current user
// you can also filter the images by group
hoodie.imagine.findOwn([group]);

// remove a single image
hoodie.imagine.remove(id);

// remove all images by current user
hoodie.imagine.removeOwn([group]);

// a preview image will be returned by a progress call (.add and .update only)
previewImage.id; // final id of the image, keep it for later ;)
previewImage.dataUrl; // dataUrl of resized image
previewImage.width; // width of resized image
previewImage.height; // height of resized image
previewImage.canvas; // canvas used for resizing, you can copy it to show a preview

// an image object has an id property and a url method. 
image.id;
image.url(type);

keep in mind

There is currently no group/type update mechanism. Your changes will be applied to new uploads only (.add, .update). You need to restart the hoodie server to apply the configuration.

example with data-url

// upload file
function handleFile(file) {
    return function(ev) {
        var dataUrl = ev.target.result;

        hoodie.imagine.add('profile', 'data:image/png;base64,...')
            .progress(function(image) { // gets only called when using data-url
                // image id and resized image is ready    
                // image properties: id, dataUrl, width, height, canvas
                            
                // show preview image
                $('img.profile-picture').attr('src', image.dataUrl);

                // or copy the canvas
                canvasContext.drawImage(image.canvas, 0, 0);
            })
            .done(function(image) {
                // image has been saved on the server
                $('img.profile-picture').attr('src', image.url('detail'));
            })
            .fail(function(error) {
                // oh noes
                console.warn(error);
            });        
    };
}



// handle selection of file input
function handleFileSelect(ev) {
    ev.preventDefault();

    var files = ev.target.files;

    $.each(files, function(index, file) {
        if (!file.type.match('image.*')) {
            return false;
        }

        var reader = new FileReader();
        reader.onload = handleFile(file);
        reader.readAsDataURL(file);
    });
}

$('#file-input').on('change', handleFileSelect);

wishlist

  • tests needed
  • catch 'quota exceeded'
  • allow uploads with blob image data e.g. by using canvas.toBlob
  • save images at hosting services
  • integrate pica for high quality frontend resizing? Current method uses a very fast step-wise canvas resizing with good quality.
  • user blacklist
  • watermark