0

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 ?

uttam
  • 435
  • 9
  • 24

1 Answers1

1

It is trying to run imagemagick's convert command but that is not there in the PATH. im4java is just an interface to run imagemagic's commmands from a java program. You need to have imagemagick in the PATH.

Kishore
  • 819
  • 9
  • 20
  • I already added jmagick to gradle dependencies, won't that suffice.And when I run the code using jmagick library it is throwing the error, not found in java library path. – uttam Feb 11 '16 at 20:15
  • in the post you mentioned im4java. jmagick is different. jmagic is a wrapper of imagemagick's c api and im4java uses the imagemagic's cli. This is clear from http://im4java.sourceforge.net/. – Kishore Feb 11 '16 at 21:19
  • I only added the dependency in gradle.build.I did not or downloaded any imagemagick tools.So , Do i need to install the imageMagick and give the PATH. – uttam Feb 12 '16 at 05:59