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:
1var features = Imagemagick.identify('kittens.jpg'); 2console.log(features);
identify(args)
Custom identification where args
is an array of arguments. The result is returned as a raw string to output
.
Example:
1var output = Imagemagick.identify(['-format', '%wx%h', 'kittens.jpg']); 2console.log('dimension: '+output);
readMetadata(path)
Read metadata (i.e. exif) in path
and return an object metadata
. Modelled on top of identify
.
Example:
1var metadata = Imagemagick.readMetadata('kittens.jpg'); 2console.log('Shot at '+metadata.exif.dateTimeOriginal);
convert(args)
Raw interface to convert
passing arguments in the array args
.
Example:
1Imagemagick.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:
1{ 2 srcPath: undefined, 3 srcData: null, 4 srcFormat: null, 5 dstPath: undefined, 6 quality: 0.8, 7 format: 'jpg', 8 progressive: false, 9 width: 0, 10 height: 0, 11 strip: true, 12 filter: 'Lagrange', 13 sharpening: 0.2, 14 customArgs: [] 15}
srcPath, dstPath and (at least one of) width and height are required. The rest is optional.
Example:
1Imagemagick.resize({ 2 srcPath: 'kittens.jpg', 3 dstPath: 'kittens-small.jpg', 4 width: 256 5}); 6console.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:
1Imagemagick.crop({ 2 srcPath: path, 3 dstPath: 'cropped.jpg', 4 width: 800, 5 height: 600, 6 quality: 1, 7 gravity: "North" 8});