title: ImageMagick convert exit status 133
body: <p>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 <a href="https://stackoverflow.com/questions/2148043/problem-with-imagemagick-and-java-runtime-exec">here</a>.</p>
  
  <pre><code>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.");
  }
  </code></pre>
  
  <p>However, when I do this, I get an exit status of <strong>133</strong> 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.</p>
  
  <p><strong>Error message:</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>Edit:</strong> Ok, so it turns out that I was getting the above error message due to Java not being able to see the <code>DYLD_LIBRARY_PATH</code> environment variable. So I restarted Eclipse and everything worked.</p>