It appears /usr/local/bin is not part of the path when electron builds the package.
I added it to my PATH in the script that uses imagemagick.
process.env.PATH += ':/usr/local/bin';
This still assumes the user has it installed on their computer.
Or you can specify the direct path.
const {identify} = require('imagemagick');
identify.path = '/usr/local/Cellar/imagemagick/7.0.8-11_2/bin/identify';
But identify relies on gs (Ghost Script) which in my case was also in /usr/local/bin. So I had to add that to my path anyway.
Also, I came across this package which I have yet to try.
https://github.com/joeherold/imagemagick-darwin-static
const os = require('os');
const path = require('path');
const graphicsmagick = require('graphicsmagick-static');
const imagemagick = require('imagemagick-darwin-static');
const {subClass} = require('gm');
let gm;
if (os.platform() == 'win32') {
gm = subClass({
appPath: path.join(graphicsmagick.path, '/')
});
} else {
gm = subClass({
imageMagick: true,
appPath: path.join(imagemagick.path, '/')
});
}
Then you can call identify or convert as needed
const getData = new Promise((resolve, reject) => {
gm(filepath).identify({}, (err, features) => {
if (err) {
reject(err);
}
resolve(features);
});
});