Created
June 16, 2012 13:35
-
-
Save orangeclover/2941350 to your computer and use it in GitHub Desktop.
Twitterアカウント(@は含まない)が記載の一覧ファイルからアイコンをダウンロードし、座席表用のアカウントつき画像を作成する座席表職人のためのGroovyスクリプト
This file contains hidden or 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
| @Grab('org.twitter4j:twitter4j-core:[2.2.4,)') | |
| import twitter4j.* | |
| import groovy.swing.j2d.GraphicsRenderer | |
| import javax.imageio.ImageIO | |
| if (!args || args.size() !=1) { | |
| println "usge:groovy TwitterProfileImageDownLoader.groovy ListFile.txt" | |
| System.exit(1) | |
| } | |
| def listFile = new File(args[0]) | |
| listFile.eachLine { | |
| assert it.getClass() == String | |
| def id = it | |
| def imgUrl = new TwitterFactory().getInstance().getProfileImage(id, ProfileImage.NORMAL).URL | |
| try { | |
| img = ImageIO.read(imgUrl.toURL()) | |
| gr = new GraphicsRenderer() | |
| gr.renderToFile("@${id}.png", img.width + 100, img.height + 20){ | |
| antialias("on") | |
| image(image: img, x:0,y:0) | |
| font(new java.awt.Font('Tahoma', java.awt.Font.BOLD, 15)) | |
| text( x:0, y:img.height + 5, text: "@${id}", borderColor: no, fill: 'blue') | |
| } | |
| } catch (Exception e) { | |
| println "${id} 例外発生:" | |
| e.printStackTrace() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment