I need to use ImageMagic in my java project. I already installed ImageMagic-7.0.3 on Windows 10 (command line works fine)
Then, i added dependency to im4java in maven file. When i try to do some action like:
public static void main(String[] args) {
String imPath="C:\\Program Files\\ImageMagick-7.0.3-Q16";
ConvertCmd cmd = new ConvertCmd();
cmd.setSearchPath(imPath);
IMOperation op = new IMOperation();
op.addImage("biuro.jpg");
op.negate();
op.addImage("biuro_new.jpg");
try {
cmd.run(op);
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IM4JavaException e) {
e.printStackTrace();
}
System.out.println("works");
}
i get following error
org.im4java.core.CommandException: java.io.FileNotFoundException: convert
at org.im4java.core.ImageCommand.run(ImageCommand.java:219)
at Main.main(Main.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.io.FileNotFoundException: convert
at org.im4java.process.ProcessStarter.searchForCmd(ProcessStarter.java:661)
at org.im4java.process.ProcessStarter.startProcess(ProcessStarter.java:399)
at org.im4java.process.ProcessStarter.run(ProcessStarter.java:312)
at org.im4java.core.ImageCommand.run(ImageCommand.java:215)
... 6 more
I went trough half of Internet. Read half of google. There was only one small advice saying "have you installed Visual C++ Redistributable and reboot?" That was the solution.
ImageMagick worked in command line, so I did not expected requirement of that type. Moreover I did not find a thing about it in both - im4java and ImageMagick reference.
Hope this will be helpful, and noone ever will waste about 5h of life searching the answer.