Ali Awad Abu Ras
Ali Awad Abu Ras

Reputation: 31

TypeError: gm.compare is not a function

I using Node v6.9.2 , I want to compare two images to each other and get the result, but its seems like the gm.compare is not a function!

If I removed the "subClass({ imageMagick: true });" error will appears Error: spawn gm ENOENT what should I do to solve this issue. Thanks

// The code

var gm = require('gm').subClass({ imageMagick: true });
gm.compare('testImg.jpg', 'testImg-1.jpg', function (err, isEqual, equality, raw, path1, path2) {
    if (err) return handle(err);
    console.log('The images were equal: %s', isEqual);
    console.log('Actual equality: %d', equality);
    console.log(raw);
    console.log(path1, path2);
});

Upvotes: 0

Views: 1057

Answers (1)

Eduardo Pinheiro
Eduardo Pinheiro

Reputation: 3789

It may help other developers, since this question is more than 3 years old.

You can find the answer in this link https://github.com/aheckmann/gm/issues/259#issuecomment-36515805

Basically you need to replace 'gm' with 'gm()'. Example:

var gm = require('gm').subClass({ imageMagick: true });
gm().compare(file1, file2, function(){});

Upvotes: 2

Related Questions