Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

imagemagick-convert

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imagemagick-convert

ImageMagick binding over convert functionality

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

imagemagick-convert

Node.js wrapper for ImageMagick CLI for simple converting images.

Prerequisites

  • Node.js >= 7.10.1
  • ImageMagick >= 6.9.5

Installation

With NPM:

npm install --save imagemagick-convert

With Yarn:

yarn add imagemagick-convert

ImageMagick installation (see more details):

OSCommand
OS Xbrew install imagemagick
Ubuntu/Debianapt-get install imagemagick
Centos/RHELyum install ImageMagick
Alpineapk add --update imagemagick

Example

import {readFileSync} from 'fs';
import {convert} from 'imagemagick-convert';

// somewhere in async function
const imgBuffer = await convert({
    srcData: readFileSync('./origin.jpg'),
    srcFormat: 'JPEG',
    width: 100,
    height: 100,
    resize: 'crop',
    format: 'PNG'
});

Original JPEG:

Original image

Converted to PNG and resized:

fitfillcrop
Original imageOriginal imageOriginal image

API reference

convert(options: Object):Promise<Buffer> - converts images

Options:

AttributeTypeRequiredDefaultDescription
srcDataBuffer*source image
srcFormatDictionaryauto-detectionsource file format (explicit specification), for more details see ImageMagick Supported Image Formats
widthIntegersource widthoutput image width in pixels
heightIntegersource heightoutput image height in pixels
resizeEnumcropstyle of resizing: crop, fit, fill
densityInteger600density/resolution for rendering an image from vector formats such as Postscript, PDF, WMF, SVG
backgroundStringnonebackground color or transparency for images
gravityDictionaryCentergravity option, for more details see ImageMagick gravity options
formatDictionarysource formatoutput file format, for more details see ImageMagick Supported Image Formats
qualityInteger75JPEG/MIFF/PNG compression level: 1 - 100
blurFloat0blur level: 0 - 1
rotateInteger0rotating degrees
flipBooleanfalsevertical flip

Keywords

FAQs

Package last updated on 04 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc