image-diff icon indicating copy to clipboard operation
image-diff copied to clipboard

Option to specify path for ImageMagick in gm

Open shukriadams opened this issue 8 years ago • 3 comments

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.

shukriadams avatar Jan 01 '17 19:01 shukriadams

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

twolfson avatar Jan 02 '17 00:01 twolfson

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.

shukriadams avatar Jan 02 '17 08:01 shukriadams

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

twolfson avatar Jan 02 '17 10:01 twolfson