/** * 验证码 */ public function verify() { $Img = new \Org\Util\Image(); $Img->buildImageVerify(); }
function thumb($image = null, $width = 0, $height = 0, $mode = 3) { if (!$image) { $defaults = D('Banner')->getBannerByName('default_thumb'); if ($defaults) { $image = $defaults[rand(0, count($defaults) - 1)]['path']; } } if (!is_file(C('WWW_ROOT') . $image)) { return ''; } $image = '/' . trim($image, '/'); // gif图片不处理 if (stripos($image, '.gif') !== false) { return $image; } if (!$width && !$height) { return $image; } if (C('IMAGE_CUT_TYPE') == 'image') { $mode = 'i'; } $postfix = '-' . $width . '-' . $height . '-' . $mode; $result_image = preg_replace('#(\\w+)\\.(\\w+)$#', "\\1{$postfix}.\\2", $image); $result_path = C('WWW_ROOT') . $result_image; if (!file_exists($result_path)) { if (C('IMAGE_CUT_TYPE') == 'image') { Org\Util\Image::convert(C('WWW_ROOT') . $image, $result_path, $width, $height); } else { // support png transparent $obj = new \Think\Image(C('WWW_ROOT') . $image); $obj->thumb($width, $height, $mode); $obj->save($result_path); } } return $result_image; }
/** * @example 验证码 */ public function verify() { $Img = new \Org\Util\Image(); $Img->buildImageVerify(4, 1, 'png', 100, 50); }