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

image-magick-js

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-magick-js

ImageMagick wrapper javascript

  • 0.1.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

ImageMagickJS

ImageMagick wrapper for nodeJS.
ImageMagick should be installed on dev and prod machine in order to work.
For windows users you need to add a PATH env variable called "magick" and linking to magick.exe.
Latest release can be found at imagemagick.org.

Feel free to contribute.
More commands will come soon.
If you want one you can open an issue ticket.

Install

Install using your package manager :

npm i --save image-magick-js
or
yarn add image-magick-js

Import the package in your js / ts file :

const  magick = require("image-magick-js");
or
import magick from "image-magick-js";

Available commands

Commands can be used with a classic promise or inside an async function using await.

custom

Send custom command to magick.

Parameters :
options : string, magick command with custom options

const options = "convert -background lightblue -fill blue \
      -pointsize 72 label:christophe \
      label.gif";
magick.custom(options)
.then((response) => console.log(response))
.catch((e) => {console.log(e);});

convert

format

Parameters :
sourceFile : string, path to source image.
targetFile : string, path to target image.

const params={
    sourceFile: string,
    targetFile: string,
}
magick.convert.format(params)
.then((response) => console.log(response))
.catch((e) => {console.log(e);});

resize

Parameters :
sourceFile : string, path to source image.
resize : string, new size, can be "50%", "800x600" or "4096@".
force : boolean, optional, force the new size even if ratio is not preserved.
targetFile : string, optional, path to target image
If the file doesn't exist it will be created.
If the parameter is not defined targeted file will be the source file.

const params={
    sourceFile: string,
    resize: string,
    targetFile: string,
    force: boolean,
}
magick.convert.resize(params)
.then((response) => console.log(response))
.catch((e) => {console.log(e);});

caption

Parameters :
targetFile : string, path to target image (if the file doesn't exist it will be created).
caption : string, text you want to write inside image.
pointSize : number, optional, font size.
size : string, optional, image ratio.
gravity : string, optional, text position ("Center", "South", "North", "East", "West", "NorthWest", "NorthEast", "SouthWest", "SouthEast").

const params={
    targetFile: string,
    caption: string,
    pointSize: number,
    size: string,
    gravity: string
}
magick.convert.caption(params)
.then((response) => console.log(response))
.catch((e) => {console.log(e);});

identify

Parameters :
file : string, file to analyse

magick.identify(file)
.then((response) => console.log(response))
.catch((e) => {console.log(e);});

response object is like this :
{
    filename: string;
    imageFormat: string;
    widthXheight: string;
    pageWidthXpageHeightXoffsetYoffset: string;
    colorspace: string;
    weight: string;
    userTime: string;
    elapsedTime: string;
    error: string;
}

Keywords

FAQs

Package last updated on 02 Dec 2021

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