import java.util.*;
import org.im4java.core.*;
import org.im4java.process.*;
// im4java-0.97.0-bin.tar.bz2を解凍してim4java-0.97.0.jarはclasspathに通す
public class Im4java7
{
public static void main(String args[])
throws Exception
{
try
{
// ConvertCmd convert = new ConvertCmd();
ImageCommand convert = new WindowsConvertCmd();
// 上下に連結
IMOperation op = new IMOperation();
op.addImage("sample3b.jpg");
op.addImage("sample6.jpg");
op.append();
op.addImage("sample944a.png");
convert.run(op);
// 左右に連結
IMOperation op2 = new IMOperation();
op2.addImage("sample3b.jpg");
op2.addImage("sample6.jpg");
op2.p_append();
op2.addImage("sample944b.png");
convert.run(op2);
}
catch(CommandException cex)
{
System.out.println(cex.getErrorText());
cex.printStackTrace();
}
}
// im4java 0.97
static class WindowsConvertCmd extends ImageCommand
{
public WindowsConvertCmd()
{
setCommand("cmd");
setCommand("/c");
setCommand("convert");
/* another way
setCommand("C:\\Program Files\\ImageMagick-6.4.9-Q16\\convert");
*/
}
}
}
元画像1(sample3b.jpg)

元画像2(sample6.jpg)

出力画像1(sample944a.png)

出力画像2(sample944b.png)

関連情報
im4javaのまとめ
im4javaで画像を円形に切り取る
im4javaのホームページ
im4java
No comments:
Post a Comment