001 package railo.commons.img; 002 003 import java.awt.Color; 004 import java.awt.image.BufferedImage; 005 import java.io.File; 006 import java.io.FileOutputStream; 007 import java.io.IOException; 008 009 public class TestCaptcha { 010 011 public static void main(String[] args) throws IOException { 012 Captcha captcha=new Captcha(); 013 014 // generate captcha image 015 BufferedImage image = captcha.generate( 016 Captcha.randomString(10), // Text 017 450, // width 018 70, // height 019 new String[]{"arial","courier new"}, // fonts 020 true, // use anti alias 021 Color.BLACK, // font color 022 45, // font size 023 Captcha.DIFFICULTY_HIGH // difficulty 024 ); 025 026 // write out captcha image as a png file 027 FileOutputStream fos = new FileOutputStream(new File("/Users/mic/temp/captcha.png")); 028 Captcha.writeOut(image, fos, "png"); 029 030 // write out captcha image as a jpg file 031 fos = new FileOutputStream(new File("/Users/mic/temp/captcha.jpg")); 032 Captcha.writeOut(image, fos, "jpg"); 033 034 } 035 }