imagemagick-cli: ImageMagick CLI Wrapper for Node.js

0.5.0 · active · verified Wed Apr 22

This package, `imagemagick-cli`, provides a robust and platform-independent Node.js interface for executing ImageMagick command-line tools. Currently at version 0.5.0, it differentiates itself by safely handling system-specific nuances, most notably mitigating the "Windows convert issue" where the `convert` command can conflict with a built-in Windows utility. It offers cross-platform compatibility, tested and verified across macOS, Linux, and Windows, supporting both ImageMagick 6 and 7 installations. The library is designed to wrap existing CLI tools, focusing on reliable execution rather than reimplementing ImageMagick's functionality in JavaScript. Releases are generally infrequent, driven by the need to address compatibility issues or improve stability.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates executing an ImageMagick command and retrieving its version using the `imagemagick-cli` wrapper, with error handling for common installation issues.

const imagemagickCli = require('imagemagick-cli');

async function checkImageMagick() {
  try {
    // Execute a simple ImageMagick command to get its version
    const { stdout, stderr } = await imagemagickCli.exec('convert -version');
    console.log(`ImageMagick convert command output:\n${stdout}`);
    if (stderr) {
      console.error(`ImageMagick convert stderr:\n${stderr}`);
    }

    // Use the dedicated getVersion method for convenience
    const version = await imagemagickCli.getVersion();
    if (version) {
      console.log(`Detected ImageMagick version via getVersion(): ${version}`);
    } else {
      console.warn('imagemagick-cli could not detect ImageMagick version via getVersion(). Ensure it is installed and in your system PATH.');
    }
  } catch (error) {
    console.error('Failed to execute ImageMagick command or detect version:', error.message);
    console.error('Please ensure ImageMagick is installed on your system and accessible in the PATH environment variable.');
  }
}

checkImageMagick();

view raw JSON →