문제

ImageMagick commands are not working from JAVA code.

Runtime.getRuntime().exec("compare /Users/labuser/Downloads/test.jpg /Users/labuser/Downloads/test1.jpg /Users/labuser/Downloads/differnce.jpg");

Exception:

java.io.IOException: Cannot run program "compare": error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)

When i tried from Terminal it works fine and produced output file in specified path. I have verified for echo $PATH and it set to be

PATH=/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/ImageMagick/bin

Anyone please suggest me for should i need to add something to work these command from Terminal? For other commands it working fine from terminal and error only with imageMagick commands

도움이 되었습니까?

해결책

Thanks @ trashgod

Its working while specifying the full path to ImageBrick API's like

    Runtime.getRuntime().exec("/opt/ImageMagick/bin/compare /Users/labuser/Downloads/test.jpg /Users/labuser/Downloads/test1.jpg /Users/labuser/Downloads/diff.jpg");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top