You are here

function _image_captcha_image_size in CAPTCHA 7

Same name and namespace in other branches
  1. 8 image_captcha/image_captcha.module \_image_captcha_image_size()

Helper function for calculating image height and width based on given code and current font/spacing settings.

Return value

array array($width, $heigh)

2 calls to _image_captcha_image_size()
image_captcha_captcha in image_captcha/image_captcha.module
Implements hook_captcha().
_image_captcha_generate_image in image_captcha/image_captcha.user.inc
Base function for generating a image CAPTCHA.

File

image_captcha/image_captcha.module, line 188
Implements image CAPTCHA for use with the CAPTCHA module

Code

function _image_captcha_image_size($code) {

  // Get settings.
  $font_size = (int) variable_get('image_captcha_font_size', 30);
  $character_spacing = (double) variable_get('image_captcha_character_spacing', '1.2');
  $characters = _image_captcha_utf8_split($code);
  $character_quantity = count($characters);

  // Calculate height and width.
  $width = $character_spacing * $font_size * $character_quantity;
  $height = 2 * $font_size;
  return array(
    $width,
    $height,
  );
}