image-diff
image-diff copied to clipboard
Option to specify path for ImageMagick in gm
I'm having a problem getting image-diff to work on some systems. I cannot reliably include ImageMagick in my OS's PATH, as I have another utility called "convert.exe" already in PATH. When image-diff calls ImageMagick's convert.exe via gm, it hits the wrong convert.exe.
gm has a workaround for this - you can initialize it with options.appPath where appPath is the path to ImageMagick, bypassing the need to map it at the OS level. This of course requires that image-diff also has an appPath option. I have a quick-and-dirty example at https://github.com/shukriadams/image-diff/blob/master/lib/image-diff.js (line 248-ish), would it be possible it implement something similar to this?
Thanks.
I'm down for supporting this but it seems strange there is no environment variable to do that (e.g. libraries will often allow PHANTOMJS_BIN or similar to specify the executable path). I'm going to open an issue on gm to see if we can add that support so all dependent libraries don't need to support passing in appPath
Thanks - that sounds like a better approach. Also, I noticed that your createDiff flow calls imageMagic directly, instead of via gm, and it also assumes imageMagic is added to PATH.
Ah, good eye. I'm sure we can replace that with gm's _exec or _spawn when the upstream issue is settled and we upgrade for support
https://github.com/aheckmann/gm/blob/1.23.0/lib/command.js#L180-L208