Pregunta

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

¿Fue útil?

Solución

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");
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top