I added gradle dependency for im4java 1.4.0. And trying to run the application in my linux system.
Here's the Code
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
IMOperation op = new IMOperation();
op.addImage();
op.resize(400, 500);// input
op.addImage("png:-"); // output: stdout
BufferedImage image = ImageIO.read(new URL("http://pic.youmobile.org/imgcdn/google_icon_play_materiel.png"));
// set up command
ConvertCmd convert = new ConvertCmd();
Stream2BufferedImage s2b = new Stream2BufferedImage();
convert.setOutputConsumer(s2b);
// run command and extract BufferedImage from OutputConsumer
convert.run(op,image);
BufferedImage img = s2b.getImage();
ImageIO.write(img, "png", new File("output.png"));
}
But It was throwing the error
Exception in thread "main" org.im4java.core.CommandException: java.io.IOException: Cannot run program "convert": error=2, No such file or directory
at org.im4java.core.ImageCommand.run(ImageCommand.java:219)
at com.quixey.media.service.converter.Test.main(Test.java:33)
Caused by: java.io.IOException: Cannot run program "convert": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at org.im4java.process.ProcessStarter.startProcess(ProcessStarter.java:407)
at org.im4java.process.ProcessStarter.run(ProcessStarter.java:312)
at org.im4java.core.ImageCommand.run(ImageCommand.java:215)
... 1 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:248)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 4 more
What was this error about ?How to fix it ?
This code worked for me on my Mac.