How can I create a CAPTCHA image with ColdFusion?
CAPTCHA images contain distorted text that is human-readable but not machine-readable.
The <cfimage> tag allows you to create CAPTCHA images. You can specify the text you want to distort, the height and width of the text area, font and font size, and the level of difficulty (affects readability).
Note: As per the ColdFusion docs, in order for the CAPTCHA image to display, the width value must be greater than: fontSize times the number of characters specified in text times 1.08.
<cfset size = 25 * 11 * 1.08/>
<cfimage action="captcha" fontSize="25" width="#size#" height="50"
text="ThisIsATest" fonts="Verdana,Arial,Courier New,Courier" difficulty="low">
This question was written by Jeremy Petersen.
It was last updated on December 6, 2007 at 5:46:33 PM EST.
CFML Referenced
Categories
Comments
Comment made by Tony on December 27, 2007 at 11:48 AM
I am guessing this is a ColdFusion 8 feature only? The CFIMAGE tag is not recognized with my CF 7.0.2
Comment made by Raymond Camden on December 27, 2007 at 11:51 AM
Yes. The idea of the site is that it ALWAYS covers the most recent version. I need to update the FAQ though as it still says 7.
Comment made by Seb Duggan on January 19, 2008 at 6:56 AM
Be careful if you're using a <cfimage> CAPTCHA on a dark background - the images have transparent backgrounds! See my blog post for details: http://sebduggan.com/posts/cfimage-generating-unreadable-captchas