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

imagemagick2

v0.1.5

Published

ImageMagick module for NodeJS that is built with MagickWand API.

Readme

ImageMagic module for NodeJS

Tested with

  • Linux x64
  • Windows x86 / Visual Studio 2015
  • ImageMagic 6.9.6
  • NodeJS 6.7.0

Installation

  1. Install ImageMagic 6.9.6
  2. Windows only configure IMAGEMAGICK_HOME environment variable to root of ImageMagic installation (e.g. C:\Program Files (x86)\ImageMagick-6.9.6-Q16-HDRI )
  3. Windows only If you have problems with ssize_t during build comment line #246 in %IMAGEMAGICK_HOME%\include\magick\magick-baseconfig.h (typedef int ssize_t) TODO: Solve this issue in better way
  4. npm install imagemagic2
  5. electorn only You may need to rebuild library for specific node version user in electron

Usage

Basic Example

To use imagemagick first you need to create and image, currently only reading from file is supported.

const image = require('imagemagick2');

var img = image(filePath);

Than you can apply transformations and/or calculations on image with fluent style. Note than transformations/calculations and even reading image from file will be performed only after apply() method is called.

    const image = require('imagemagick2');
    image(filePath) // Do nothing just save action
        .resize(640, 480) // Do nothing just save action
        .write(destinationPath) // Do nothing just save action
        .apply(); //Apply all actions

Apply returns promise.

    const image = require('imagemagick2');

    image(filePath)
        .resize(640)
        .write(destination)
        .apply()
        .than(() => console.log("OK"))
        .catch(err => console.log("Error: " + err)); 

To handle results of every action you can use action callback. In case of any error action callback will not be called and global promise will fail;

    const image = require('imagemagick2');

    image(filePath)
        .resize(640, 480, function(img){ console.log("Resize finished") })
        .write(destination)
        .apply();

Additionally you can perform any custom action after any operation with method do.

    const image = require('imagemagick2');

    image(filePath)
        .resize(640, 480)
        .do(function(img) { console.log("Resize finished") })
        .write(destination)
        .apply();

Apply time actions

In some cases you may need to decide to continue some transformations or not based on results of previous transformations/calculations. In that case you can use apply time actions.

    const image = require('imagemagick2');

    image(filePath)
        .size(function(img, size) { 
                if(size.width > 640) 
                    img.resize(640)
                       .write(destination); 
              })
        .apply();

Methods

Resize

    const image = require('imagemagick2');
    image(filePath).resize(640, 480, function(img){});

Rotate

    const image = require('imagemagick2');
    image(filePath).rotate(90 /* angle in degrees */, function(img){}); 

Write

    const image = require('imagemagick2');
    image(filePath).write(destinationFilePath, function(img){}); 

Grayscale

    const image = require('imagemagick2');
    image(filePath).grayscale(function(img){}); 

Strip (remove all additional data like EXIF or thumbnails)

    const image = require('imagemagick2');
    image(filePath).strip(function(img){}); 

Size (retrieves image size)

    const image = require('imagemagick2');
    image(filePath).size(function(img, size) { console.log(size.width, size.height) }); 

Brightness histogram

    const image = require('imagemagick2');
    image(filePath).brightnessHistogram(40 /* histogram components number*/, 
            function(img, hist /* array of values, each between 0 and 1 */) { });