@Grab(group='com.jhlabs', module='filters', version='2.0.235') import java.awt.* import java.awt.image.* import java.io.* import javax.imageio.* import com.jhlabs.composite.* import com.jhlabs.image.* // 画像を回転させる def img = ImageIO.read(new File("sf2.jpg")) def imga = new BufferedImage( img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_ARGB ) def gr = imga.createGraphics() gr.drawImage(img,0,0,null) gr.dispose() def rf = new RotateFilter((float)45f/180f*ImageMath.PI, true) imga = rf.filter(imga, null) ImageIO.write(imga, "png", new File("rotate.png"))
元画像
出力画像
動作環境
groovy 1.8.6, JDK7 update4
No comments:
Post a Comment