Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 460
DanielGibbs Avatar asked Feb 10 '11 04:02

DanielGibbs


2 Answers

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

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

like image 100
Sebastian Pipping Avatar answered Sep 28 '22 16:09

Sebastian Pipping


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.

like image 44
lakemalcom Avatar answered Sep 28 '22 14:09

lakemalcom