import org.im4java.core.*;
// im4java-0.96.0-bin.tar.bz2を解凍してim4java-0.96.0.jarはclasspathに通す
public class Im4java1
{
 public static void main(String args[])
     throws Exception
 {
     try
     {
         IMOperation op = new IMOperation();
         op.addImage("sf.jpg");
         op.alpha("activate");
         op.virtualPixel("transparent");
         op.distort("perspective",
         "0,0, 50,50, 200,0, 150,50, 0,200, 0,200, 200,200, 200,200");
         op.addImage("sample919a.png");
//            ConvertCmd convert = new ConvertCmd();
         ImageCommand convert = new WindowsConvertCmd();
         convert.run(op);
     }
     catch(CommandException cex)
     {
         System.out.println(cex.getErrorText());
         cex.printStackTrace();
     }
 }
 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");
*/
     }
 }
}
元画像(sf.jpg)
出力画像(sample919a.png)

関連情報
im4javaのまとめ
ImageMagickで台形変形を行う
im4javaのホームページ
 
No comments:
Post a Comment