Coder Social home page Coder Social logo

meteor-imagemagick's Introduction

Meteor Imagemagick

Meteor wrapped library node-imagemagick into a synchronous API, using Futures.

Installation

You need at least version 0.6.5 of Meteor.

Meteor Imagemagick can be installed with Meteorite. From inside a Meteorite-managed app:

$ mrt add imagemagick

API

Based on node-imagemagick original doc.

identify(path)

Identify file at path and return an object features.

Example:

var features = Imagemagick.identify('kittens.jpg');
console.log(features);

identify(args)

Custom identification where args is an array of arguments. The result is returned as a raw string to output.

Example:

var output = Imagemagick.identify(['-format', '%wx%h', 'kittens.jpg']);
console.log('dimension: '+output);

readMetadata(path)

Read metadata (i.e. exif) in path and return an object metadata. Modelled on top of identify.

Example:

var metadata = Imagemagick.readMetadata('kittens.jpg');
console.log('Shot at '+metadata.exif.dateTimeOriginal);

convert(args)

Raw interface to convert passing arguments in the array args.

Example:

Imagemagick.convert(['kittens.jpg', '-resize', '25x120', 'kittens-small.jpg']);

resize(options)

Convenience function for resizing an image, modelled on top of convert.

The options argument have the following default values:

{
  srcPath: undefined,
  srcData: null,
  srcFormat: null,
  dstPath: undefined,
  quality: 0.8,
  format: 'jpg',
  progressive: false,
  width: 0,
  height: 0,
  strip: true,
  filter: 'Lagrange',
  sharpening: 0.2,
  customArgs: []
}

srcPath, dstPath and (at least one of) width and height are required. The rest is optional.

Example:

Imagemagick.resize({
  srcPath: 'kittens.jpg',
  dstPath: 'kittens-small.jpg',
  width:   256
});
console.log('resized kittens.jpg to fit within 256x256px');

crop(options)

Convenience function for resizing and cropping an image. crop uses the resize method, so options and callback are the same. crop uses options.srcPath, so make sure you set it :) Using only options.width or options.height will create a square dimensioned image. Gravity can also be specified, it defaults to Center. Available gravity options are [NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast]

Example:

Imagemagick.crop({
  srcPath: path,
  dstPath: 'cropped.jpg',
  width: 800,
  height: 600,
  quality: 1,
  gravity: "North"
});

meteor-imagemagick's People

Contributors

sylvaingi avatar

Watchers

James Cloos 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.