Giter Site home page Giter Site logo

imagemagick-native-promise's Introduction

imagemagick-native-promise

Build Status

JavaScript Promise wrapper for node-imagemagick-native

Features

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);
})

imagemagick-native-promise's People

Contributors

greenlikeorange avatar xurei avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.