1

When I use ImageMagick+im4java in eclipse, I always has this error:

Exception in thread "main" org.im4java.core.CommandException: java.io.FileNotFoundException: convert
    at org.im4java.core.ImageCommand.run(ImageCommand.java:219)
    at imagetools.ImageTools.resizeImage(ImageTools.java:71)
    at imagetools.ImageTools.main(ImageTools.java:92)
Caused by: java.io.FileNotFoundException: convert
    at org.im4java.process.ProcessStarter.searchForCmd(ProcessStarter.java:661)
    at org.im4java.process.ProcessStarter.startProcess(ProcessStarter.java:403)
    at org.im4java.process.ProcessStarter.run(ProcessStarter.java:312)
    at org.im4java.core.ImageCommand.run(ImageCommand.java:215)

And I am sure that the itself ImageMagick works well on my computer(Mac OSX 10.10.1). Here is my code:

package imagetools;


import org.im4java.process.ProcessStarter;

import org.im4java.core.ConvertCmd;
import org.im4java.core.IMOperation;


public class ImageTools {       
public static void resizeImage(int width, int height, String srcPath, String newPath) throws Exception {
        IMOperation op = new IMOperation();
        op.addImage(srcPath);       
        op.resize(width, height);
        op.addImage(newPath);        
        ConvertCmd convert = new ConvertCmd();               
        convert.run(op);
    }   
public static void main(String[] args) throws Exception{
        String src =  "/Users/lvxinyun/Downloads/im4java-1.4.0/images.src/rose1.jpg"; 
        String n = "/Users/lvxinyun/Downloads/im4java-1.4.0/images.src/rose1_n.jpg";
        ProcessStarter.setGlobalSearchPath("/Users/lvxinyun/Downloads/ImageMagick-6.9.0-5");
        resizeImage(600,800,src,n);
    }
}
Xinyun Lv
  • 11
  • 1
  • 3

3 Answers3

5
cd C:\Program Files\ImageMagick-7.0.5-Q16
copy magick.exe convert.exe
Pang
  • 9,564
  • 146
  • 81
  • 122
钟医手
  • 51
  • 1
  • 2
-1

You have to install ImageMagick-6.9.1-10-Q16-x64-dll.exe and set IM4JAVA_TOOLPATH = "C:\Program Files\ImageMagick-6.9.1-Q16 (your install path)

You can look here for more details: http://im4java.sourceforge.net/docs/dev-guide.html

EugZol
  • 6,476
  • 22
  • 41
-1

It is important to set the class path. Download latest version of ImageMagick and exiftool. Install ImageMagick. Create a String var using the installation directory.

String myPath = "C:\\Program Files\\ImageMagick-7.0.8-Q16;C:\\Program Files\\exiftool-11.53";

Set it as OS command as mentioned below:

ProcessStarter.setGlobalSearchPath(myPath);

Reference

nitin
  • 75
  • 1
  • 12