Dec 22 / Richard Knop

Making Zend_Captcha_Image easier to read

Sometimes people will complain that the captcha is too difficult to read and they have to reload the page in order to be able to pass the captcha test. If you are not willing to say goodbye to the very flexible Zend_Captcha_Image there are only two ways how to make it easier to read:

  1. Use different font (I have found that Arial is sometimes hard to read, a good replacement seems to be LBRITED.TTF).
  2. Set lower dot and line noise level.

You can use “dotNoiseLevel” and “lineNoiseLevel” to tune down the captcha noise (and surpisingly this is not mentioned in the Zend Framework documentation):

  1. $captcha = new Zend_Form_Element_Captcha('captcha', array(
  2.     'label' => 'Captcha',
  3.     'helper' => null,
  4.     'captcha' => array(
  5.         'captcha' => 'Image',
  6.         'wordLen' => 5,
  7.         'timeout' => 300, // 5 minutes timeout
  8.         'font' => 'fonts/LBRITED.TTF',
  9.         'fontSize' => 20,
  10.         'width' => 100,
  11.         'height' => 60,
  12.         'imgDir' => 'images/captcha/',
  13.         'imgUrl' => '/images/captcha/',
  14.         'dotNoiseLevel' => 15,
  15.         'lineNoiseLevel' => 1
  16.     )
  17. ));

Above I went over the top perhaps. Nevertheless, you must be able to find a compromise so that the users will be happy and the security side of your website won’t suffer too much.

Leave a Comment