Skip to content

nelsonic/imagemagic-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

imagemagic-test

A few simple tests with node-imagemagic


node-imagemagic identify method works fine by its self.

var im = require('imagemagick');
var assert = require('assert');

console.log("Current Directory: "+__dirname);
var parentDir = __dirname.substring(0, __dirname.lastIndexOf('/'));
console.log("Parent Directory: " + parentDir);

var filename = parentDir+'/sample-images/kittens.jpg';

im.identify(filename, function(err, ia) { // ia = image attibutes
    console.log("Filename: " + filename);
    assert.equal(ia.width, 1600);
    assert.equal(ia.height, 1200);
});

If you download this repo and run npm install followed by: istanbul cover lib you will see 100% coverage (i.e. we are executing im.identify successfully):

identify method working

However when I try to wrap im.identify in a method (with a callback) it fails:

var IR = {}

/* * Trying to Wrap the im.identify in a function with callback * */

IR.getOriginalImageAttributes = function(filename, callback) {
  return im.identify(filename, function(err, ia) {
    console.log("Filename: " + filename);
    console.log(ia);
    callback(ia);       // do something with the image attributes
  });
};

/* * * * */

module.exports = IR;

identify method fails when wrapped

What am I doing wrong?

About

A few simple tests with node-imagemagic

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published