选择语言 :

 Core_Captcha::image_create

Creates an image resource with the dimensions specified in config. If a background image is supplied, the image dimensions are used.

void Core_Captcha::image_create( [ string $background = null ] )
throws
Kohana_Exception if no GD2 support

参数列表

参数 类型 描述 默认值
$background string Path to the background image file null
返回值
  • void
File: ./core/classes/captcha.class.php
protected function image_create($background = null)
{
    // Check for GD2 support
    if (!function_exists('imagegd2'))Core::show_500(__('captcha.requires_GD2'));

    // Create a new image (black)
    Captcha::$image = imagecreatetruecolor(Captcha::$config['width'], Captcha::$config['height']);

    // Use a background image
    if ( !empty($background) )
    {
        /*
        // Create the image using the right function for the filetype
        $function = 'imagecreatefrom' . Captcha::image_type($filename);
        Captcha::$background_image = $function($background);

        // Resize the image if needed
        if ( imagesx(Captcha::background_image) !== Captcha::$config['width'] or imagesy(Captcha::background_image) !== Captcha::$config['height'] )
        {
            imagecopyresampled(Captcha::image, Captcha::background_image, 0, 0, 0, 0, Captcha::$config['width'], Captcha::$config['height'], imagesx(Captcha::background_image), imagesy(Captcha::background_image));
        }

        // Free up resources
        imagedestroy(Captcha::background_image);

        */
    }
}