org\Verify::_background PHP Метод

_background() приватный Метод

绘制背景图片 注:如果验证码输出图片比较大,将占用比较多的系统资源
private _background ( )
    private function _background()
    {
        $path = dirname(__FILE__) . '/verify/bgs/';
        $dir = dir($path);
        $bgs = [];
        while (false !== ($file = $dir->read())) {
            if ('.' != $file[0] && substr($file, -4) == '.jpg') {
                $bgs[] = $path . $file;
            }
        }
        $dir->close();
        $gb = $bgs[array_rand($bgs)];
        list($width, $height) = @getimagesize($gb);
        // Resample
        $bgImage = @imagecreatefromjpeg($gb);
        @imagecopyresampled($this->_image, $bgImage, 0, 0, 0, 0, $this->imageW, $this->imageH, $width, $height);
        @imagedestroy($bgImage);
    }