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

imagemagick-nodejs

v0.2.2

Published

A comprehensive Node.js wrapper for ImageMagick CLI

Readme

⚠️ Notice — This package is currently in beta. APIs may change before the stable release. Please report any issues you encounter on GitHub.

ImageMagick Node.js

A comprehensive, type-safe Node.js wrapper for ImageMagick CLI

npm version License: MIT Node.js Version TypeScript

FeaturesInstallationQuick StartAPI ReferenceError HandlingContributing


✨ Features

  • 📥 Zero Configuration — Bundled ImageMagick binaries, automatically downloaded on install
  • 🔒 Full TypeScript Support — Comprehensive type definitions and type-safe APIs
  • ⚡ Dual Module Support — ESM and CommonJS compatibility via tsup
  • 🎨 High-Level Fluent API — Chainable methods for intuitive image processing
  • 🔧 Low-Level Command Wrappers — Direct access to all ImageMagick tools
  • 📦 Batch Processing — Process multiple images with built-in progress tracking
  • 🌊 Stream Support — Efficient memory usage with streaming operations
  • 🌍 Cross-Platform — Windows, macOS, and Linux (glibc & musl)

📦 Installation

npm install imagemagick-nodejs

That's it! ImageMagick binaries are automatically downloaded during installation.

Supported Platforms

| Platform | Architectures | Notes | | -------- | ------------- | -------------------------------- | | Windows | x64, x86 | Portable static build | | macOS | arm64, x64 | Bundled with dylibs | | Linux | amd64, arm64 | glibc and musl (Alpine) variants |

Using System ImageMagick

To skip the bundled binary and use your system's ImageMagick instead:

IMAGEMAGICK_SKIP_DOWNLOAD=1 npm install imagemagick-nodejs

🚀 Quick Start

import { imageMagick, identify, convert } from 'imagemagick-nodejs';

// High-level fluent API
await imageMagick('input.jpg').resize(800, 600).quality(85).blur(2).toFile('output.webp');

// Get image information
const info = await identify('image.jpg');
console.log(`${info.width}x${info.height} ${info.format}`);

// Low-level command builder
await convert('input.png')
  .resize(1200)
  .sharpen({ sigma: 1.5 })
  .quality(90)
  .strip()
  .output('output.jpg')
  .run();

📚 API Reference

High-Level Fluent API

import { imageMagick } from 'imagemagick-nodejs';

const image = imageMagick('input.jpg');

// Chain operations
await image
  .resize(800, 600, { fit: 'cover' })
  .crop(800, 600)
  .rotate(45, 'white')
  .blur(3)
  .sharpen(1)
  .quality(85)
  .strip()
  .toFile('output.jpg');

// Output options
await image.toFile('output.jpg'); // Write to file
const buffer = await image.toBuffer(); // Get as Buffer
const stream = await image.toStream(); // Get as stream

Command Wrappers

Convert

import { convert, runConvert, convertImage } from 'imagemagick-nodejs';

// Builder pattern
const builder = convert('input.jpg').resize(800, 600).quality(85).output('output.webp');

await runConvert(builder);

// Simple conversion
await convertImage('input.jpg', 'output.webp', {
  resize: { width: 800 },
  quality: 85,
  strip: true,
});

Identify

import { identify, getDimensions, getFormat } from 'imagemagick-nodejs';

// Full image info
const info = await identify('image.jpg');
console.log(info.format); // 'JPEG'
console.log(info.width); // 1920
console.log(info.height); // 1080
console.log(info.depth); // 8
console.log(info.colorspace); // 'sRGB'

// Quick helpers
const dims = await getDimensions('image.jpg');
const format = await getFormat('image.jpg');

Mogrify (Batch In-Place)

import { mogrify, batchResize, batchOptimize } from 'imagemagick-nodejs';

// Batch resize all JPGs in place
await batchResize('*.jpg', 800);

// Batch optimize for web
await batchOptimize('images/*.png');

Composite

import { composite, overlayImage, addWatermark } from 'imagemagick-nodejs';

// Add watermark
await addWatermark('watermark.png', 'photo.jpg', 'output.jpg', {
  gravity: 'SouthEast',
  opacity: 50,
});

// Blend images
await blendImages('image1.jpg', 'image2.jpg', 'blended.jpg', 50);

Montage

import { createContactSheet, createThumbnailGallery } from 'imagemagick-nodejs';

// Create contact sheet
await createContactSheet(['img1.jpg', 'img2.jpg', 'img3.jpg'], 'sheet.jpg', {
  columns: 3,
  tileSize: 200,
  label: true,
});

Compare

import { compareImages, areIdentical, getSSIM } from 'imagemagick-nodejs';

// Check if identical
const identical = await areIdentical('img1.jpg', 'img2.jpg');

// Get similarity score
const ssim = await getSSIM('img1.jpg', 'img2.jpg');

// Create diff image
await createDiffImage('img1.jpg', 'img2.jpg', 'diff.png');

Animate

import { createGif, createWebP, extractFrames } from 'imagemagick-nodejs';

// Create animated GIF
await createGif(['frame1.png', 'frame2.png', 'frame3.png'], 'animation.gif', {
  delay: 50,
  loop: 0,
});

// Extract frames from GIF
await extractFrames('animation.gif', 'frame-%03d.png');

Batch Processing

import { processBatch, findImages, batchOptimizeFiles } from 'imagemagick-nodejs';

// Find all images
const images = await findImages('./photos', {
  extensions: ['.jpg', '.png'],
  recursive: true,
});

// Process with progress tracking
await processBatch(
  images,
  (file) => ['convert', file, '-resize', '800x600', `output/${path.basename(file)}`],
  {
    parallel: 4,
    onProgress: ({ current, percentage }) => {
      console.log(`${percentage}% - ${current}`);
    },
  }
);

Utilities

import { isFormatSupported, getMimeType, detectFormat, extractPalette } from 'imagemagick-nodejs';

// Check format support
const supported = await isFormatSupported('webp');

// Get MIME type
const mime = getMimeType('png'); // 'image/png'

// Detect actual format (from content)
const format = await detectFormat('unknown-file');

// Extract color palette
const colors = await extractPalette('image.jpg', 8);

Binary Management

import {
  findBinary,
  setBinaryPath,
  addBinarySearchPath,
  getVersion,
  isAvailable,
  getSupportedFormats,
} from 'imagemagick-nodejs';

// Check availability
if (await isAvailable()) {
  const version = await getVersion();
  console.log(`ImageMagick ${version.version}`);
}

// Set explicit binary path (highest priority)
setBinaryPath('/custom/path/to/magick');

// Add additional search paths (checked after bundled binary)
addBinarySearchPath('/opt/imagemagick/bin/magick');

// List supported formats
const formats = await getSupportedFormats();

Binary Search Order

  1. Custom path set via setBinaryPath()
  2. Bundled binary in bin/ (downloaded during install)
  3. System PATH
  4. Common installation paths + paths added via addBinarySearchPath()

🛠️ Error Handling

import { ImageMagickError, BinaryNotFoundError, ExecutionError } from 'imagemagick-nodejs';

try {
  await convertImage('input.jpg', 'output.webp');
} catch (error) {
  if (error instanceof BinaryNotFoundError) {
    console.error('ImageMagick not found. Please install it.');
  } else if (error instanceof ExecutionError) {
    console.error(`Command failed: ${error.stderr}`);
  }
}

🤝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for details on:

  • Development setup and workflow
  • Coding standards and conventions
  • Testing guidelines
  • Pull request process

🙏 Acknowledgments

Built on top of ImageMagick — a powerful suite of image manipulation tools.