本文整理汇总了PHP中imagestring函数的典型用法代码示例。如果您正苦于以下问题:PHP imagestring函数的具体用法?PHP imagestring怎么用?PHP imagestring使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagestring函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: translucentWatermark
public static function translucentWatermark($originalImage, $watermark, $saveFile = null, $outputFileTipe = 'jpg')
{
$tempFolder = "temp/";
//$fileRandomValue = 0;
$cache = $tempFolder . $saveFile . '.' . $outputFileTipe;
// Load the stamp and the photo to apply the watermark to
if (strstr($originalImage, '.jpg') !== false) {
$im = imagecreatefromjpeg($originalImage);
} elseif (strstr($originalImage, '.png') !== false) {
$im = imagecreatefrompng($originalImage);
}
// First we create our stamp image manually from GD
$stamp = imagecreatetruecolor(100, 70);
imagefilledrectangle($stamp, 0, 0, 99, 69, 0xff);
imagefilledrectangle($stamp, 9, 9, 90, 60, 0xffffff);
//$im = imagecreatefromjpeg('photo.jpeg');
imagestring($stamp, 5, 20, 20, 'libGD', 0xff);
imagestring($stamp, 3, 20, 40, '(c) 2007-9', 0xff);
// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);
// Merge the stamp onto our photo with an opacity of 50%
imagecopymerge($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp), 50);
// Save the image to file and free memory
imagepng($im, $cache);
imagedestroy($im);
}
开发者ID:edarkzero,项目名称:GineObs,代码行数:29,代码来源:WatermarkCreator.php
示例2: getCode
function getCode($num, $w, $h)
{
// 去掉了 0 1 O l 等
$str = "23456789abcdefghijkmnpqrstuvwxyz";
$code = '';
for ($i = 0; $i < $num; $i++) {
$code .= $str[mt_rand(0, strlen($str) - 1)];
}
//将生成的验证码写入session,备验证页面使用
$_SESSION["my_checkcode"] = $code;
//创建图片,定义颜色值
Header("Content-type: image/PNG");
$im = imagecreate($w, $h);
$black = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
$gray = imagecolorallocate($im, 118, 151, 199);
$bgcolor = imagecolorallocate($im, 235, 236, 237);
//画背景
imagefilledrectangle($im, 0, 0, $w, $h, $bgcolor);
//画边框
imagerectangle($im, 0, 0, $w - 1, $h - 1, $gray);
//imagefill($im, 0, 0, $bgcolor);
//在画布上随机生成大量点,起干扰作用;
for ($i = 0; $i < 80; $i++) {
imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
}
//将字符随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
$strx = rand(5, 10);
for ($i = 0; $i < $num; $i++) {
$strpos = rand(1, 6);
imagestring($im, 20, $strx, $strpos, substr($code, $i, 1), $black);
$strx += $w / 5;
}
imagepng($im);
imagedestroy($im);
}
开发者ID:hanpc,项目名称:chushen,代码行数:35,代码来源:code_char.php
示例3: image
/**
* Displays the captcha image
*
* @access public
* @param int $key Captcha key
* @return mixed Captcha raw image data
*/
function image($key)
{
$value = Jaws_Utils::RandomText();
$result = $this->update($key, $value);
if (Jaws_Error::IsError($result)) {
$value = '';
}
$bg = dirname(__FILE__) . '/resources/simple.bg.png';
$im = imagecreatefrompng($bg);
imagecolortransparent($im, imagecolorallocate($im, 255, 255, 255));
// Write it in a random position..
$darkgray = imagecolorallocate($im, 0x10, 0x70, 0x70);
$x = 5;
$y = 20;
$text_length = strlen($value);
for ($i = 0; $i < $text_length; $i++) {
$fnt = rand(7, 10);
$y = rand(6, 10);
imagestring($im, $fnt, $x, $y, $value[$i], $darkgray);
$x = $x + rand(15, 25);
}
header("Content-Type: image/png");
ob_start();
imagepng($im);
$content = ob_get_contents();
ob_end_clean();
imagedestroy($im);
return $content;
}
开发者ID:Dulciane,项目名称:jaws,代码行数:36,代码来源:Simple.php
示例4: action_index
/**
* Processes incoming text
*/
public function action_index()
{
$this->request->headers['Content-type'] = 'image/png';
// Grab text and styles
$text = arr::get($_GET, 'text');
$styles = $_GET;
$hover = FALSE;
try {
// Create image
$img = new PNGText($text, $styles);
foreach ($styles as $key => $value) {
if (substr($key, 0, 6) == 'hover-') {
// Grab hover associated styles and override existing styles
$hover = TRUE;
$styles[substr($key, 6)] = $value;
}
}
if ($hover) {
// Create new hover image and stack it
$hover = new PNGText($text, $styles);
$img->stack($hover);
}
echo $img->draw();
} catch (Exception $e) {
if (Kohana::config('pngtext.debug')) {
// Dump error message in an image form
$img = imagecreatetruecolor(strlen($e->getMessage()) * 6, 16);
imagefill($img, 0, 0, imagecolorallocate($img, 255, 255, 255));
imagestring($img, 2, 0, 0, $e->getMessage(), imagecolorallocate($img, 0, 0, 0));
echo imagepng($img);
}
}
}
开发者ID:andygoo,项目名称:kohana-pngtext,代码行数:36,代码来源:pngtext.php
示例5: codeimage
static function codeimage()
{
$image = imagecreatetruecolor(100, 30);
$bgcolor = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $bgcolor);
$code = '';
for ($i = 0; $i < 4; $i++) {
$fontsize = 6;
$fontcolor = imagecolorallocate($image, rand(0, 120), rand(0, 120), rand(0, 120));
$data = "abcdefghjkmnpqrstuvwxy3456789";
$fontcontent = substr($data, rand(1, strlen($data) - 1), 1);
$code .= $fontcontent;
$x = $i * 100 / 4 + rand(5, 10);
$y = rand(5, 10);
imagestring($image, $fontsize, $x, $y, $fontcontent, $fontcolor);
}
for ($i = 0; $i < 200; $i++) {
$pointcolor = imagecolorallocate($image, rand(50, 200), rand(50, 200), rand(50, 200));
imagesetpixel($image, rand(1, 99), rand(1, 29), $pointcolor);
}
for ($i = 0; $i < 2; $i++) {
$linecolor = imagecolorallocate($image, rand(80, 220), rand(80, 220), rand(80, 220));
imageline($image, rand(1, 99), rand(1, 29), rand(1, 99), rand(1, 29), $linecolor);
}
$return['code'] = $code;
$return['image'] = $image;
return $return;
// header('content-type:image/png');
// imagepng($image);
}
开发者ID:HivenKay,项目名称:ESalon,代码行数:30,代码来源:LfCodeimage.php
示例6: imgcode
function imgcode($nums, $width, $high)
{
//去除了數字0和1 字母小寫O和L,為了避免辨識不清楚
//$str = "23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMOPQRSTUBWXYZ";
$str = "0123456789";
$code = '';
for ($i = 0; $i < $nums; $i++) {
$code .= $str[mt_rand(0, strlen($str) - 1)];
}
$_SESSION['captcha'] = $code;
//建立圖示,設置寬度及高度與顏色等等條件
$image = imagecreate($width, $high);
$black = imagecolorallocate($image, mt_rand(0, 200), mt_rand(0, 200), mt_rand(0, 200));
$border_color = imagecolorallocate($image, 21, 106, 235);
$background_color = imagecolorallocate($image, 235, 236, 237);
//建立圖示背景
imagefilledrectangle($image, 0, 0, $width, $high, $background_color);
//建立圖示邊框
imagerectangle($image, 0, 0, $width - 1, $high - 1, $border_color);
//在圖示布上隨機產生大量躁點
for ($i = 0; $i < 80; $i++) {
imagesetpixel($image, rand(0, $width), rand(0, $high), $black);
}
$strx = rand(3, 8);
for ($i = 0; $i < $nums; $i++) {
$strpos = rand(1, 6);
imagestring($image, 5, $strx, $strpos, substr($code, $i, 1), $black);
$strx += rand(10, 30);
}
imagepng($image);
imagedestroy($image);
}
开发者ID:FantasticThought,项目名称:tfsda,代码行数:32,代码来源:captcha.php
示例7: __construct
/**
* Class constructor generates the CAPTCHA image.
*
* @return blob the image
* @access public
*/
function __construct()
{
session_start();
$image = imagecreate($this->width, $this->height);
$random_str = $this->gen_str($this->chars_nr);
#md5( microtime() ); // md5 to generate the random string
$result_str = substr($random_str, 0, $this->chars_nr);
//trim $chars_nr digit
$bg_color = imagecolorallocate($image, $this->background_color['red'], $this->background_color['green'], $this->background_color['blue']);
// background color
$tx_color = imagecolorallocate($image, $this->text_color['red'], $this->text_color['gree'], $this->text_color['blue']);
// text color
for ($i = 0; $i <= $this->lines; $i++) {
$line_color = imagecolorallocate($image, rand(0, 255), rand(0, 255), rand(0, 255));
//line color
imageline($image, rand(rand(-10, 100), rand(-10, 100)), rand(rand(-10, 100), rand(-10, 100)), rand(rand(-10, 100), rand(-10, 100)), rand(rand(-10, 100), rand(-10, 100)), $line_color);
// Create lines on image
}
imagestring($image, 5, 20, 10, $result_str, $tx_color);
// Draw a random string horizontally
$_SESSION['key'] = $result_str;
// Carry the data through session
header("Content-type: image/png");
// Out out the image
imagepng($image);
// Output image to browser
}
开发者ID:rehash,项目名称:Repository,代码行数:33,代码来源:class.rshcaptcha.php
示例8: generateCaptcha
public function generateCaptcha()
{
//make image
$im = imagecreatetruecolor($this->width, $this->height);
//set background
$bg_color = imagecolorallocate($im, mt_rand($this->bg_color_min, $this->bg_color_max), mt_rand($this->bg_color_min, $this->bg_color_max), mt_rand($this->bg_color_min, $this->bg_color_max));
//padding
imagefill($im, 0, 0, $bg_color);
//add lines
for ($i = 0; $i < $this->lines; $i++) {
//set color
$line_color = imagecolorallocate($im, mt_rand($this->line_color_min, $this->line_color_max), mt_rand($this->line_color_min, $this->line_color_max), mt_rand($this->line_color_min, $this->line_color_max));
//draw line
imageline($im, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $line_color);
}
//add pixels
for ($i = 0; $i < $this->pixels; $i++) {
//set color
$pixels_color = imagecolorallocate($im, mt_rand($this->pixels_color_min, $this->pixels_color_max), mt_rand($this->pixels_color_min, $this->pixels_color_max), mt_rand($this->pixels_color_min, $this->pixels_color_max));
//draw pixels
imagesetpixel($im, mt_rand(0, $this->width), mt_rand(0, $this->height), $pixels_color);
}
//get captcha string
$captcha = $this->generateString();
//set color of font
$str_color = imagecolorallocate($im, mt_rand($this->font_color_min, $this->font_color_max), mt_rand($this->font_color_min, $this->font_color_max), mt_rand($this->font_color_min, $this->font_color_max));
//put string to picture
imagestring($im, $this->font, ceil($this->width / 2) - 20, ceil($this->height / 2) - 10, $captcha, $str_color);
//save or output
imagepng($im);
//destroy res
imagedestroy($im);
}
开发者ID:billywl,项目名称:shop,代码行数:33,代码来源:Captcha.class.php
示例9: makeGraphicalCaptcha
/**
* Makes a graphical captcha from the provided text string
*
* @param string $captcha_text string to make image captcha from
* @return string $data_url a data url containing the obfuscated image
*/
function makeGraphicalCaptcha($captcha_text)
{
$image = @imagecreatetruecolor(195, 35);
// defines background color, random lines color and text color
$bg_color = imagecolorallocate($image, mt_rand(0, 255), 255, 0);
imagefill($image, 0, 0, $bg_color);
$lines_color = imagecolorallocate($image, 0x99, 0xcc, 0x99);
$text_color = imagecolorallocate($image, mt_rand(0, 255), 0, 255);
// draws random lines
for ($i = 0; $i < 4; $i++) {
imageline($image, 0, rand(0, 35), 195, rand(0, 35), $lines_color);
}
$captcha_letter_array = str_split($captcha_text);
foreach ($captcha_letter_array as $i => $captcha_letter) {
imagesetthickness($image, 1);
imagestring($image, 5, 5 + $i * 35, rand(2, 14), $captcha_letter, $text_color);
}
// creates image
ob_start();
imagejpeg($image);
$image_data = ob_get_contents();
ob_end_clean();
$data_url = "data:image/jpeg;base64," . base64_encode($image_data);
imagedestroy($image);
return $data_url;
}
开发者ID:yakar,项目名称:yioop,代码行数:32,代码来源:captcha_model.php
示例10: imagecharx
function imagecharx($img, $char, $x0, $y0, $ylist)
{
global $bk_color, $fg_color;
$da = @imagecreate(10, 20) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($da, $bk_color[0], $bk_color[1], $bk_color[2]);
$text_color = imagecolorallocate($da, $fg_color[0], $fg_color[1], $fg_color[2]);
$color = imagecolorallocate($img, $fg_color[0], $fg_color[1], $fg_color[2]);
$arg = rand(0, 18) / 100.0 * pi();
imagestring($da, 18, 0, 0, $char, $text_color);
for ($i = 0; $i < 200; $i++) {
$y = @floor($i / 10);
$x = $i % 10;
$point_color = imagecolorat($da, $x, $y);
if ($point_color == $text_color) {
for ($j = 0; $j < 12; $j++) {
$dx = 0;
$dy = 0;
$p = 6;
for ($s = 0; $s < $p; $s++) {
$dx += rand(0, 1000 / $p) / 100;
$dy += rand(0, 1000 / $p) / 100;
}
$xx = $x * 5 + $dx - 25;
$yy = $y * 5 + $dy - 50;
$x1 = cos($arg) * $xx - sin($arg) * $yy + 25;
$y1 = sin($arg) * $xx + cos($arg) * $yy + 50;
imagesetpixel($img, $x0 + $x1, $y0 + $y1, $color);
}
}
}
imagedestroy($da);
}
开发者ID:sdgdsffdsfff,项目名称:json-db,代码行数:32,代码来源:spray.php
示例11: create_image
function create_image()
{
header("Content-Type: image/png");
$image = imagecreatetruecolor(200, 50) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($image, 0, 0, 0);
$text_color = imagecolorallocate($image, 122, 111, 255);
$line_color = imagecolorallocate($image, 64, 64, 64);
$pixel_color = imagecolorallocate($image, 0, 0, 255);
imagefilledrectangle($image, 0, 0, 200, 50, $background_color);
for ($i = 0; $i < 3; $i++) {
imageline($image, 0, rand(0, 255) % 50, 200, rand(0, 255) % 50, $line_color);
}
for ($i = 0; $i < 1000; $i++) {
imagesetpixel($image, rand() % 200, rand() % 50, $pixel_color);
}
$letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$len = strlen($letters);
$letter = $letters[rand(0, $len - 1)];
# $text_color = imagecolorallocate($image, 0, 0, 0);
$word = "";
for ($i = 0; $i < 6; $i++) {
$letter = $letters[rand(0, $len - 1)];
imagestring($image, 7, 5 + $i * 30, 20, $letter, $text_color);
$word .= $letter;
}
$_SESSION['solution'] = $word;
imagepng($image);
imagedestroy($image);
}
开发者ID:sagarpopat,项目名称:HACKIM-2015,代码行数:29,代码来源:imagedemo.php
示例12: createImage
protected function createImage($width, $height)
{
$im = imagecreate($width, $height);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "Простая Текстовая Строка", $text_color);
imagepng($im, $this->tmpFile);
}
开发者ID:fhteam,项目名称:laravel-validator,代码行数:7,代码来源:ImageDimensionValidationRuleTest.php
示例13: drawRating
function drawRating($rating, $max, $type)
{
if ($type == 0) {
$image = imagecreatetruecolor(102, 15);
$back = ImageColorAllocate($image, 250, 250, 250);
$border = ImageColorAllocate($image, 0, 0, 0);
$fill = ImageColorAllocate($image, 0, 235, 0);
ImageFilledRectangle($image, 0, 0, 101, 14, $back);
ImageFilledRectangle($image, 1, 1, $rating / $max * 100, 14, $fill);
ImageRectangle($image, 0, 0, 101, 14, $border);
$textcolor = imagecolorallocate($image, 0, 0, 0);
imagestring($image, 5, 35, 0, $rating / $max * 100 . '%', $textcolor);
} else {
if ($rating > $max) {
$rating = $max;
}
$image = imagecreatetruecolor(10 * ($rating + 2) + 2, 15);
$back = ImageColorAllocate($image, 250, 250, 250);
$border = ImageColorAllocate($image, 0, 0, 0);
$fill = ImageColorAllocate($image, 235, 0, 0);
ImageFilledRectangle($image, 0, 0, 10 * ($rating + 2) + 1, 14, $back);
ImageFilledRectangle($image, 1, 1, 10 * $rating, 14, $fill);
ImageRectangle($image, 0, 0, 10 * $rating + 1, 14, $border);
$textcolor = imagecolorallocate($image, 0, 0, 0);
imagestring($image, 5, 10 * ($rating + 1), 0, $rating, $textcolor);
}
imagepng($image);
imagedestroy($image);
}
开发者ID:noahrichards,项目名称:pb,代码行数:29,代码来源:pngbar.php
示例14: getCode
function getCode($num, $w, $h)
{
$code = "";
for ($i = 0; $i < $num; $i++) {
$code .= rand(0, 9);
}
//4位验证码也可以用rand(1000,9999)直接生成
//将生成的验证码写入session,备验证页面使用
$_SESSION['yzm'] = $code;
//setcookie("mimi", md5($code), time()+1200);
//创建图片,定义颜色值
Header("Content-type: image/PNG");
$im = imagecreate($w, $h);
$black = imagecolorallocate($im, 255, 0, 63);
$gray = imagecolorallocate($im, 200, 200, 200);
$bgcolor = imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bgcolor);
//画边框
//imagerectangle($im, 0, 0, $w-1, $h-1, $black);
//在画布上随机生成大量黑点,起干扰作用;
for ($i = 0; $i < 10; $i++) {
imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
}
//将数字随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
$strx = rand(1, 3);
for ($i = 0; $i < $num; $i++) {
$strpos = rand(2, 6);
imagestring($im, 5, $strx, $strpos, substr($code, $i, 1), $black);
$strx += rand(8, 12);
}
imagepng($im);
imagedestroy($im);
}
开发者ID:313801120,项目名称:AspPhpCms,代码行数:33,代码来源:YZM_7.php
示例15: create_image
function create_image()
{
// *** Generate a passcode using md5
// (it will be all lowercase hex letters and numbers ***
$md5 = md5(rand(0, 9999));
$pass = substr($md5, 10, 5);
// *** Set the session cookie so we know what the passcode is ***
$_SESSION["pass"] = $pass;
// *** Create the image resource ***
$image = ImageCreatetruecolor(100, 20);
// *** We are making two colors, white and black ***
$clr_white = ImageColorAllocate($image, 255, 255, 255);
$clr_black = ImageColorAllocate($image, 0, 0, 0);
// *** Make the background black ***
imagefill($image, 0, 0, $clr_black);
// *** Set the image height and width ***
imagefontheight(15);
imagefontwidth(15);
// *** Add the passcode in white to the image ***
imagestring($image, 5, 30, 3, $pass, $clr_white);
// *** Throw in some lines to trick those cheeky bots! ***
imageline($image, 5, 1, 50, 20, $clr_white);
imageline($image, 60, 1, 96, 20, $clr_white);
// *** Return the newly created image in jpeg format ***
return imagejpeg($image);
// *** Just in case... ***
imagedestroy($image);
}
开发者ID:phpsa,项目名称:TheHostingTool,代码行数:28,代码来源:captcha_image.php
示例16: create_captcha
function create_captcha($width = 60, $height = 32)
{
session_start();
//生成验证码图片
Header("Content-type: image/PNG");
$im = imagecreate($width, $height);
// width and height of image
$back = ImageColorAllocate($im, 245, 245, 245);
// specify background color
imagefill($im, 0, 0, $back);
// fill the background color into image
$vcodes = "";
srand((double) microtime() * 1000000);
//生成4位数字
for ($i = 0; $i < 4; $i++) {
$font = ImageColorAllocate($im, rand(100, 255), rand(0, 100), rand(100, 255));
// 生成随机颜色
$authnum = rand(1, 9);
$vcodes .= $authnum;
imagestring($im, 5, 2 + $i * 10, 1, $authnum, $font);
}
for ($i = 0; $i < 100; $i++) {
// interuppting
$randcolor = ImageColorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
imagesetpixel($im, rand() % 70, rand() % 30, $randcolor);
// 画像素点函数
}
ImagePNG($im);
ImageDestroy($im);
$_SESSION['captcha'] = $vcodes;
}
开发者ID:NingerJohn,项目名称:vfinder,代码行数:31,代码来源:code.php
示例17: create_image
function create_image()
{
$image = imagecreatetruecolor(200, 50);
$background_color = imagecolorallocate($image, 255, 255, 255);
imagefilledrectangle($image, 0, 0, 200, 50, $background_color);
$line_color = imagecolorallocate($image, 255, 0, 255);
for ($i = 0; $i < 10; $i++) {
imageline($image, 0, rand() % 50, 200, rand() % 25, $line_color);
}
$pixel_color = imagecolorallocate($image, 255, 0, 255);
for ($i = 0; $i < 1000; $i++) {
imagesetpixel($image, rand() % 200, rand() % 50, $pixel_color);
}
$letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
$len = strlen($letters);
$letter = $letters[rand(0, $len - 1)];
$text_color = imagecolorallocate($image, 0, 0, 0);
$word = "";
for ($i = 0; $i < 6; $i++) {
$letter = $letters[rand(0, $len - 1)];
imagestring($image, 5, 5 + $i * 30, 20, $letter, $text_color);
$word .= $letter;
}
$_SESSION['security_key'] = $word;
imagepng($image);
}
开发者ID:matrixdevuk,项目名称:SweatyCaptcha,代码行数:26,代码来源:gen.php
示例18: create_captcha
/**
* +----------------------------------------------------------
* 图片上传的处理函数
* +----------------------------------------------------------
*/
function create_captcha()
{
$word = $this->create_word();
// 把验证码字符串写入session
$_SESSION['captcha'] = md5($word . DOU_SHELL);
// 绘制基本框架
$im = imagecreatetruecolor($this->captcha_width, $this->captcha_height);
$bg_color = imagecolorallocate($im, 235, 236, 237);
imagefilledrectangle($im, 0, 0, $this->captcha_width, $this->captcha_height, $bg_color);
$border_color = imagecolorallocate($im, 118, 151, 199);
imagerectangle($im, 0, 0, $this->captcha_width - 1, $this->captcha_height - 1, $border_color);
// 添加干扰
for ($i = 0; $i < 5; $i++) {
$rand_color = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imagearc($im, mt_rand(-$this->captcha_width, $this->captcha_width), mt_rand(-$this->captcha_height, $this->captcha_height), mt_rand(30, $this->captcha_width * 2), mt_rand(20, $this->captcha_height * 2), mt_rand(0, 360), mt_rand(0, 360), $rand_color);
}
for ($i = 0; $i < 50; $i++) {
$rand_color = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imagesetpixel($im, mt_rand(0, $this->captcha_width), mt_rand(0, $this->captcha_height), $rand_color);
}
// 生成验证码图片
$text_color = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
imagestring($im, 6, 18, 5, $word, $text_color);
// header
header("Cache-Control: max-age=1, s-maxage=1, no-cache, must-revalidate");
header("Content-type: image/png;charset=utf-8");
/* 绘图结束 */
imagepng($im);
imagedestroy($im);
return true;
}
开发者ID:phphonor,项目名称:companycms,代码行数:36,代码来源:captcha.class.php
示例19: index
public function index()
{
header("content-type:image/gif");
$this->load->library('session');
$width = 60;
$height = 30;
$img = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($img, 255, 255, 255);
$color = imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255));
$str = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$code = "";
for ($i = 0; $i < 5; $i++) {
$code .= $str[rand(0, strlen($str) - 1)];
}
$this->session->set_userdata(array('myCode' => strtolower($code)));
imagefilledrectangle($img, 0, 0, 60, 30, $color);
for ($i = 0; $i < 100; $i++) {
imagesetpixel($img, rand(0, 60), rand(0, 30), imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255)));
}
for ($i = 0; $i < 10; $i++) {
imageline($img, rand(0, 60), rand(0, 30), rand(0, 60), rand(0, 30), imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255)));
}
imagestring($img, 5, 10, 5, $code, $white);
return imagegif($img);
//imagedestroy($img);
}
开发者ID:804485808,项目名称:local_motors,代码行数:26,代码来源:imgcode.php
示例20: getCode
function getCode($w, $h)
{
$im = imagecreate($w, $h);
//imagecolorallocate($im, 14, 114, 180); // background color
$red = imagecolorallocate($im, 255, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
$num1 = rand(1, 20);
$num2 = rand(1, 20);
$_SESSION['helloweba_math'] = $num1 + $num2;
$gray = imagecolorallocate($im, 118, 151, 199);
$black = imagecolorallocate($im, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
//画背景
imagefilledrectangle($im, 0, 0, 100, 24, $black);
//在画布上随机生成大量点,起干扰作用;
for ($i = 0; $i < 80; $i++) {
imagesetpixel($im, rand(0, $w), rand(0, $h), $gray);
}
imagestring($im, 5, 5, 4, $num1, $red);
imagestring($im, 5, 30, 3, "+", $red);
imagestring($im, 5, 45, 4, $num2, $red);
imagestring($im, 5, 70, 3, "=", $red);
imagestring($im, 5, 80, 2, "?", $white);
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
}
开发者ID:CodingJason,项目名称:totemvision,代码行数:26,代码来源:code_math.php
注:本文中的imagestring函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论