ImageMagick converts exit status 133

I am using ImageMagick's conversion tool to convert images from my Java program running on Mac OS X. I am using the following code, which I adapted from here .

public static void convertToJPG(String originalFile, String newFile) throws Exception {
    executeCommand("/usr/local/ImageMagick-6.6.7/bin/convert", originalFile, newFile);
}

private static void executeCommand(String... command) throws Exception {
    ProcessBuilder pb = new ProcessBuilder(command);
    pb.redirectErrorStream(true);
    Process p = pb.start();
    int exitStatus = p.waitFor();
    System.out.println(exitStatus);
    if(exitStatus != 0)
        throw new Exception("Error converting image.");
}

However, when I do this, I get exit status 133 and the error message below. I assume this has something to do with permissions, since when I run the same command from the terminal, it works fine.

Error message:

dyld: Library not loaded: /ImageMagick-6.6.7/lib/libMagickCore.4.dylib
  Referenced from: /usr/local/ImageMagick-6.6.7/bin/convert
  Reason: image not found

Edit: Ok, so it turns out that I got the above error message due to Java being unable to see the environment variable DYLD_LIBRARY_PATH. So I restarted Eclipse and it worked.

+5
3

133, , . , , ImageMagick . , Runtime.exec(), : .

+3

133 = 128 + 5 = < > + SIGTRAP

. http://tldp.org/LDP/abs/html/exitcodes.html "kill -l".

+4

You should use jmagick , which provides the Java API for native imagemagick libraries. This is more efficient than creating new processes from your Java application.

0
source

All Articles