Created
April 4, 2013 12:42
-
-
Save yenjoji/5310058 to your computer and use it in GitHub Desktop.
どうでもいいテスト用の画像ファイルを生成するGroovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.* | |
import java.awt.image.* | |
import javax.imageio.* | |
long lastmod = System.currentTimeMillis() | |
(1..2000).each{ | |
def bi = new BufferedImage(2048, 1364, BufferedImage.TYPE_INT_RGB) | |
def g = bi.createGraphics() | |
g.setBackground(Color.black) | |
int fontsize = 1200 / Math.max( 1 , ( Math.round(Math.log10(it) + 0.5) -2 ) ) | |
g.setFont(new Font("Monospaced", Font.PLAIN, fontsize)) | |
g.setColor(Color.white) | |
g.drawString("${it}", 200, 1182 ) | |
def out = new File("/tmp/testimg/${it}.jpg") | |
ImageIO.write(bi, "jpg", out) | |
out.setLastModified(lastmod - ( 1000L * 60 * 60 * 24 * it)) | |
print "." | |
if(it % 10 == 0){ | |
println "" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment