@Grab(group='com.jhlabs', module='filters', version='2.0.235') import java.awt.* import java.awt.image.* import java.awt.geom.* import java.io.* import javax.imageio.* import com.jhlabs.composite.* import com.jhlabs.image.* // 画像に光沢をつける def img = ImageIO.read(new File("sf2.jpg")) def img2 = new BufferedImage( img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_ARGB ) // 半透明グラデーション作成 def gr = img2.createGraphics() gr.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ) GradientPaint gp = new GradientPaint( 0, 0, new Color(0xff, 0xff, 0xff, 0xc0), 0, (int)img.getHeight()*2/3, new Color(0xff, 0xff, 0xff, 0x00) ) gr.setPaint(gp) def path = new Path2D.Double() path.moveTo(img.getWidth(), 0) path.lineTo((int)img.getWidth()*2/3, 0) path.lineTo(img.getWidth(), (int)img.getHeight()*2/3) gr.fill(path) gr.dispose() // 明るさを75% def ctf = new ContrastFilter() ctf.setBrightness(0.75f) img = ctf.filter(img, null) gr = img.createGraphics() gr.drawImage(img2,0,0,null) gr.dispose() ImageIO.write(img, "png", new File("gloss.png"))
元画像
出力画像
動作環境
groovy 1.8.6, JDK7 update4
No comments:
Post a Comment