在Mac上我是經過 Homebrew來進行ImageMagick的安裝的 html
一、安裝brew java
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)」
$ brew install imagemagick
「Advantages of im4java: the interface of the IM commandline is quite stable, so your java program (and the im4java-library) will work across many versions of IM. im4java also provides a better OO interface (the "language" of the IM-commandline with it's postfix-operation notation translates very easily into OO-notation). And most important: you can use im4java everywhere JMagick can't be used because of the JNI hazard (e.g. java application servers).」 git
四、實現 github
ProcessStarter.setGlobalSearchPath("/usr/local/bin/"); IMOperation op = new IMOperation(); op.addImage("/Users/liyinjun/Desktop/12.jpg"); op.resize(100,200); op.addImage("/Users/liyinjun/Desktop/new_12.jpg"); ConvertCmd convert = new ConvertCmd(); try { convert.run(op); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IM4JavaException e) { // TODO Auto-generated catch block e.printStackTrace(); }
下面是轉換的圖片 shell
這裏是im4java 使用嚮導 http://im4java.sourceforge.net/docs/dev-guide.html ruby