You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by da...@cocoon.zones.apache.org on 2005/09/05 01:58:47 UTC

[DAISY] Created: CaptchaReader

A new document has been created.

http://cocoon.zones.apache.org/daisy/documentation/687.html

Document ID: 687
Branch: main
Language: default
Name: CaptchaReader
Document Type: Document
Created: 9/4/05 11:58:39 PM
Creator (owner): Pier Fumagalli
State: publish

Parts
=====

Content
-------
Mime type: text/xml
Size: 3366 bytes
Content:
<html>
<body>

<p>The <tt>CaptchaReader</tt> is a simple reader generating JPEG images for the
text supplied as its source in a way so that it's hard to parse automatically.
</p>

<p><em>CAPTCHA</em> means quite literally <em>Completely Automated Public Turing
Test to Tell Computers and Humans Apart</em> and one of the best resources on
this can be found at the <a href="http://www.captcha.net/">Carnegie Mellon
School of Computer Science CAPTCHA project.</a>.</p>

<p>This reader creates very simple <em>CAPTCHAs</em> from within a Cocoon
pipeline, enabling quick and safe end-user presence identification. As an
example, look at the following pipeline snippet:</p>

<pre> &lt;map:match pattern="*"&gt;
   &lt;map:read type="captcha" src="{1}"/&gt;
 &lt;/map:match&gt;</pre>

<p>The example will produce an image containing the text in "<tt>{1}</tt>"
"warped" or "bent" in a way similar to the Adobe® Photoshop® "<em>Wave</em>"
filter plugin.</p>

<p>Few pipeline parameters control the operation of the <tt>CaptchaReader</tt>
(this component is not configurable):</p>

<ul>
<li><tt>width</tt>: the width of the image to generate <em>(default: 100)</em>.
</li>
<li><tt>height</tt>: the height of the image to generate <em>(default:
50)</em>.</li>
<li><tt>foreground</tt>: the text foreground color<em> (default: random)</em>.
</li>
<li><tt>background</tt>: the image background color <em>(default: white)</em>.
</li>
<li><tt>font</tt>: the font to use for the text <em>(default: serif)</em>.</li>
<li><tt>scale</tt>: the scaling factor for interim images <em>(default:
5)</em>.</li>
<li><tt>amount</tt>: the amount of text warping to apply <em>(default: 1)</em>.
</li>
<li><tt>quality</tt>: the JPEG encoding quality<em> (default: 0.75)</em>.</li>
</ul>

<p>Note that when the <tt>foreground</tt> parameter is not specified, the color
used to write the text will be randomly chosen in a way that it contrasts well
with the background color to avoid problems of illegible text.</p>

<p>Both the <tt>foreground</tt> and <tt>background</tt> parameters accept
strings in the format specified by
<a href="http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Color.html#decode%28java.lang.String%29">Color.decode(String)</a>
(for example <tt>fff</tt>, or <tt>0099CC</tt>) or one of the field names of the
<a href="http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Color.html">Color</a>
class (for example
<a href="http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Color.html#BLACK">BLACK</a>
or
<a href="http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Color.html#cyan">cyan</a>
...).</p>

<p>The <tt>scale</tt> parameter controls how much the specified size should be
scaled while processing the interim images: the bigger the scaling factor, the
better the image quality, but also the memory used while generating the final
image will be bigger. In other words, use this with care.</p>

<p>The <tt>amount</tt> parameter is interpreted as a floating point number and
must be greater than zero. This controls how much text should be warped, and
normally a value of 1 produce quite-good warping. Increasing (or decreasing)
this value will produce more (ore less) warping.</p>

<p>Remember that in no way the <tt>CaptchaReader</tt> claims to be able to
generate "unbreakable" text (that will be impossible), and improvements to the
algorithm are welcome.</p>

</body>
</html>

Collections
===========
The document belongs to the following collections: documentation