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

imagemagick-native-promise

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imagemagick-native-promise

Promise wrapper for node-imagemagick-native library

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

imagemagick-native-promise

Build Status

JavaScript Promise wrapper for node-imagemagick-native

Features

  • Used node-imagemagick-native
  • Used native promise library
  • Callback can used and stream API are still origin

Promise supported methods

Please look full API reference at https://github.com/elad/node-imagemagick-native/blob/master/README.md

Original's table of contents

Examples

Convert formats

Convert from one format to another with quality control:

imagemagick.convert({
	srcData: fs.readFileSync('before.jpg'),
	format: 'PNG',
	quality: 100 // (best) to 1 (worst)
})
.then((buffer) => {
  fs.writeFileSync('after.png', buffer);
})
.catch((e) => {
  console.error(e);
})

Blur

Blur image:

imagemagick.convert({
	srcData: fs.readFileSync('before.jpg'),
	blur: 5
})
.then((buffer) => {
  fs.writeFileSync('after.jpg', buffer);
})
.catch((e) => {
  console.error(e);
})

Resize

Resized images by specifying width and height. There are three resizing styles:

  • aspectfill: Default. The resulting image will be exactly the specified size, and may be cropped.
  • aspectfit: Scales the image so that it will not have to be cropped.
  • fill: Squishes or stretches the image so that it fills exactly the specified size.
imagemagick.convert({
	srcData: fs.readFileSync('before_resize.jpg'),
	width: 100,
	height: 100,
	resizeStyle: 'aspectfill', // is the default, or 'aspectfit' or 'fill'
	gravity: 'Center' // optional: position crop area when using 'aspectfill'
})
.then((buffer) => {
  fs.writeFileSync('after_resize.jpg', buffer);
})
.catch((err) => {
  console.error(err);
})

Rotate, flip, and mirror

Rotate and flip images, and combine the two to mirror:

imagemagick.convert({
	srcData: fs.readFileSync('before_rotateflip.jpg'),
	rotate: 180,
	flip: true
})
.then((buffer) => {
  fs.writeFileSync('after_rotateflip.jpg', buffer);
})
.catch((err) => {
  console.error(err);
})

Keywords

FAQs

Package last updated on 16 Nov 2017

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