DanielGibbs
DanielGibbs

Reputation: 10190

ImageMagick convert exit status 133

I am using ImageMagick's convert tool to convert images from within 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 an exit status of 133 and the error message below. I am assuming that this has something to do with permissions, as 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 was getting the above error message due to Java not being able to see the DYLD_LIBRARY_PATH environment variable. So I restarted Eclipse and everything worked.

Upvotes: 5

Views: 4152

Answers (3)

Sebastian Pipping
Sebastian Pipping

Reputation: 121

Return code 133 = 128 + 5 = <terminated by signal> + SIGTRAP

See http://tldp.org/LDP/abs/html/exitcodes.html and the output of "kill -l".

Upvotes: 4

armandino
armandino

Reputation: 18582

You should consider using jmagick which provides a Java API to the native imagemagick libraries. It's more efficient than spawning new processes from your Java app.

Upvotes: 0

lakemalcom
lakemalcom

Reputation: 1066

While I wasn't able to find anything about a 133 return code, I did notice that you aren't reading the command standard out / standard error stream. I'd suggest reading that to see if ImageMagick is giving you some more helpful output. There's a question here that deals with more complex use cases of the Runtime.exec() method, but the best basic way to do it is with this method.

Upvotes: 3

Related Questions