View Javadoc

1   /*
2    * JCaptcha, the open source java framework for captcha definition and integration
3    * Copyright (c)  2007 jcaptcha.net. All Rights Reserved.
4    * See the LICENSE.txt file distributed with this package.
5    */
6   
7   /*
8    * jcaptcha, the open source java framework for captcha definition and integration
9    * copyright (c)  2007 jcaptcha.net. All Rights Reserved.
10   * See the LICENSE.txt file distributed with this package.
11   */
12  
13  /*
14   * jcaptcha, the open source java framework for captcha definition and integration
15   * copyright (c)  2007 jcaptcha.net. All Rights Reserved.
16   * See the LICENSE.txt file distributed with this package.
17   */
18  
19  package com.octo.captcha.engine.image.utils;
20  
21  import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator;
22  import com.octo.captcha.component.image.backgroundgenerator.FileReaderRandomBackgroundGenerator;
23  import com.octo.captcha.component.image.fontgenerator.FontGenerator;
24  import com.octo.captcha.component.image.fontgenerator.TwistedAndShearedRandomFontGenerator;
25  import com.octo.captcha.component.image.textpaster.SimpleTextPaster;
26  import com.octo.captcha.component.image.textpaster.TextPaster;
27  import com.octo.captcha.component.image.wordtoimage.ComposedWordToImage;
28  import com.octo.captcha.component.image.wordtoimage.WordToImage;
29  import com.octo.captcha.component.word.wordgenerator.DummyWordGenerator;
30  import com.octo.captcha.component.word.wordgenerator.WordGenerator;
31  import com.octo.captcha.image.ImageCaptcha;
32  import com.octo.captcha.image.ImageCaptchaFactory;
33  import com.octo.captcha.image.gimpy.GimpyFactory;
34  
35  import java.awt.*;
36  import java.io.File;
37  import java.io.IOException;
38  
39  /***
40   * <p>Description: Generate a sample logo for the master webSite. Main method takes one arg : the file path of the
41   * generated logo</p>
42   *
43   * @author <a href="mailto:mag@jcaptcha.net">Marc-Antoine Garrigue</a>
44   * @version 1.0
45   */
46  public class LogoGenerator {
47  
48      public static void main(String[] args) throws IOException {
49          TextPaster paster = new SimpleTextPaster(new Integer(8),
50                  new Integer(8), Color.white);
51          BackgroundGenerator back = new FileReaderRandomBackgroundGenerator(
52                  new Integer(200), new Integer(100),
53                  "/gimpybackgrounds");
54          FontGenerator font = new TwistedAndShearedRandomFontGenerator(
55                  new Integer(30), null);
56          WordGenerator words = new DummyWordGenerator("JCAPTCHA");
57          WordToImage word2image = new ComposedWordToImage(font, back, paster);
58          ImageCaptchaFactory factory = new GimpyFactory(words, word2image);
59          ImageCaptcha pix = factory.getImageCaptcha();
60          ImageToFile.serialize(pix.getImageChallenge(), new File(args[0]));
61      }
62  }