Random image text generation?
Steven D'Aprano
steve at REMOVE.THIS.cybersource.com.au
Sun Nov 12 17:33:06 EST 2006
On Sun, 12 Nov 2006 14:56:49 -0600, skip wrote:
>
> >> Is there a module out there that will generate an image with a random
> >> text string such as the confirmation images you see on various
> >> websites?
>
> Mitja> They're called captcha images or captchas for short. Googling
> Mitja> for "python captcha" returns several hits; see what you like...
>
> Thanks. I'd never heard that term before. Assuming I can get PIL installed
> with freetype support on my Mac the ASPN recipe looks like it will do the
> trick.
Keep in mind two serious problems with captchas:
- they're impossible for the blind or people using text-only browsers to
see -- even mere colour blindness can make some captchas impossible to
solve;
- sometimes they're too difficult for even those with perfect vision to
decipher.
Two alternatives:
Instead of displaying an obfuscated image of a nonsense word, display six
randomly chosen photos, where five are of the same thing but not the same
image. E.g. you might show five different kittens and a horse. The user
has to click on the image that is not the same as the others.
State-of-the-art horse-recognition software is not yet in widespread use
by spammers *wink*
For a text only solution, consider putting up a natural language question
such as:
What is the third letter of 'national'?
What is four plus two?
How many eggs in a dozen?
Fill in the blank: Mary had a little ____ its fleece was white as snow.
Cat, Dog, Apple, Bird. One of those words is a fruit. Which one?
Beware of making the questions too difficult or too specific:
In the third season of Babylon Five, what did Mr Morden ask Lando?
Also, keep in mind that all captchas are vulnerable to the old
distributed hybrid human-machine network trick: "We'll give you a free
account on our porn site if you spend fifteen minutes a day solving
captchas for our bot network." The only solution to that, I fear, is open
season on spammers and anyone who buys from a spammer.
--
Steven.
More information about the Python-list
mailing list