Skip to content

sylvaingi/meteor-imagemagick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published