当前位置: 首页>>代码示例>>PHP>>正文


PHP ImageTTFText函数代码示例

本文整理汇总了PHP中ImageTTFText函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageTTFText函数的具体用法?PHP ImageTTFText怎么用?PHP ImageTTFText使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ImageTTFText函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     ob_clean();
     $image_handle = imagecreatetruecolor(150, 60);
     $white = imagecolorallocate($image_handle, 255, 255, 255);
     $rndm = imagecolorallocate($image_handle, rand(64, 192), rand(64, 192), rand(64, 192));
     imagefill($image_handle, 0, 0, $white);
     $fontName = PUBLICPATH . "/fonts/elephant.ttf";
     $myX = 15;
     $myY = 30;
     $angle = 0;
     for ($x = 0; $x <= 100; $x++) {
         $myX = rand(1, 148);
         $myY = rand(1, 58);
         imageline($image_handle, $myX, $myY, $myX + rand(-5, 5), $myY + rand(-5, 5), $rndm);
     }
     $myCryptBase = tep_create_random_value(50, 'digits');
     $secure_image_hash_string = "";
     for ($x = 0; $x <= 4; $x++) {
         $dark = imagecolorallocate($image_handle, rand(5, 128), rand(5, 128), rand(5, 128));
         $capChar = substr($myCryptBase, rand(1, 35), 1);
         $secure_image_hash_string .= $capChar;
         $fs = rand(20, 26);
         $myX = 15 + ($x * 28 + rand(-5, 5));
         $myY = rand($fs + 2, 55);
         $angle = rand(-30, 30);
         ImageTTFText($image_handle, $fs, $angle, $myX, $myY, $dark, $fontName, $capChar);
     }
     $this->session->set_userdata('secure_image_hash_string', $secure_image_hash_string);
     header("Content-type: image/jpeg");
     imagejpeg($image_handle, "", 95);
     imagedestroy($image_handle);
     die;
 }
开发者ID:rongandat,项目名称:ookcart-project,代码行数:34,代码来源:secure_image.php

示例2: createAICode

 function createAICode()
 {
     global $bBlog;
     $code = $this->randomString();
     $bBlog->db->query("\n\tDELETE FROM `" . T_CHECKCODE . "` WHERE `timestamp`+3000<NOW()");
     $bBlog->db->query("\n\tINSERT INTO `" . T_CHECKCODE . "` ( `id` , `checksum` , `timestamp` )\n\tVALUES ('', '" . md5($code . $_SERVER["REMOTE_ADDR"]) . "', NOW( ))");
     if (!isset($plugins_dir)) {
         $plugins_dir = dirname(__FILE__) . '/';
     }
     $fontfile = "atomicclockradio.ttf";
     $font = $plugins_dir . $fontfile;
     $im = @imageCreate(110, 50) or die("Cannot Initialize new GD image stream");
     $background_color = imageColorAllocate($im, 195, 217, 255);
     $text_color = imageColorAllocate($im, 168, 18, 19);
     ImageTTFText($im, 20, 5, 18, 38, $text_color, $font, $code);
     // Date in the past
     header("Expires: Thu, 28 Aug 1997 05:00:00 GMT");
     // always modified
     $timestamp = gmdate("D, d M Y H:i:s");
     header("Last-Modified: " . $timestamp . " GMT");
     // HTTP/1.1
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Cache-Control: post-check=0, pre-check=0", false);
     // HTTP/1.0
     header("Pragma: no-cache");
     // dump out the image
     header("Content-type: image/png");
     ImagePNG($im);
 }
开发者ID:BackupTheBerlios,项目名称:bblog-svn,代码行数:29,代码来源:authimage.class.php

示例3: createImage

 function createImage($_text, $_fontsize = 11)
 {
     /* create filename */
     $filename = 'button_' . md5($_text) . '.png';
     $filename = strtolower($filename);
     /* see if file exists already, we cache it */
     if (file_exists(PHPGW_IMAGES_FILEDIR . '/' . $filename)) {
         return $filename;
     }
     $size = imagettfbbox($_fontsize, 0, $this->font, $_text);
     $dx = abs($size[2] - $size[0]);
     $dy = abs($size[5] - $size[3]);
     $xpad = 9;
     $ypad = 9;
     $im = imagecreate($dx + $xpad, $dy + $ypad);
     $blue = ImageColorAllocate($im, 0x2c, 0x6d, 0xaf);
     $black = ImageColorAllocate($im, 0, 0, 0);
     $white = ImageColorAllocate($im, 255, 255, 255);
     ImageRectangle($im, 0, 0, $dx + $xpad - 1, $dy + $ypad - 1, $black);
     ImageRectangle($im, 0, 0, $dx + $xpad, $dy + $ypad, $white);
     ImageTTFText($im, $_fontsize, 0, (int) ($xpad / 2) + 1, $dy + (int) ($ypad / 2), -$black, $this->font, $_text);
     ImageTTFText($im, $_fontsize, 0, (int) ($xpad / 2), $dy + (int) ($ypad / 2) - 1, -$white, $this->font, $_text);
     ImagePNG($im, PHPGW_IMAGES_FILEDIR . '/' . $filename);
     ImageDestroy($im);
     return $filename;
 }
开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:26,代码来源:class.graphics.inc.php

示例4: create_error

 function create_error($text)
 {
     $text = $text;
     $size = "8";
     $font = "classes/fonts/trebuchet.ttf";
     $TextBoxSize = imagettfbbox($size, 0, $font, preg_replace("/\\[br\\]/is", "\r\n", $text));
     $TxtBx_Lwr_L_x = $TextBoxSize[0];
     $TxtBx_Lwr_L_y = $TextBoxSize[1];
     $TxtBx_Lwr_R_x = $TextBoxSize[2];
     $TxtBx_Lwr_R_y = $TextBoxSize[3];
     $TxtBx_Upr_R_x = $TextBoxSize[4];
     $TxtBx_Upr_R_y = $TextBoxSize[5];
     $TxtBx_Upr_L_x = $TextBoxSize[6];
     $TxtBx_Upr_L_y = $TextBoxSize[7];
     $width = max($TxtBx_Lwr_R_x, $TxtBx_Upr_R_x) - min($TxtBx_Lwr_L_x, $TxtBx_Upr_L_x);
     $height = max($TxtBx_Lwr_L_y, $TxtBx_Lwr_R_y) - min($TxtBx_Upr_R_y, $TxtBx_Upr_L_y);
     $x = -min($TxtBx_Upr_L_x, $TxtBx_Lwr_L_x);
     $y = -min($TxtBx_Upr_R_y, $TxtBx_Upr_L_y);
     $img = imagecreate($width + 2, $height + 1);
     // Only PHP-Version 4.3.2 or higher
     if (function_exists('imageantialias')) {
         imageantialias($img, FALSE);
     }
     $white = imagecolorallocate($img, 255, 255, 255);
     $black = imagecolorallocate($img, 0, 0, 0);
     imagecolortransparent($img, $white);
     ImageTTFText($img, $size, 0, $x, $y, $black, $font, preg_replace("/<br>/is", "\r\n", $text));
     header("Content-Type: image/png");
     ImagePNG($img);
     ImageDestroy($img);
     exit;
 }
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:32,代码来源:class.thumbnail.php

示例5: TextToImage

function TextToImage($text, $separate_line_after_chars = 40, $size = 24, $rotate = 0, $padding = 2, $transparent = true, $color = array('red' => 0, 'grn' => 0, 'blu' => 0), $bg_color = array('red' => 255, 'grn' => 255, 'blu' => 255))
{
    $amount_of_lines = ceil(strlen($text) / $separate_line_after_chars);
    $x = explode("\n", $text);
    $final = '';
    foreach ($x as $key => $value) {
        $returnes = '';
        do {
            $first_part = mb_substr($value, 0, $separate_line_after_chars, 'utf-8');
            $value = "\n" . mb_substr($value, $separate_line_after_chars, null, 'utf-8');
            $returnes .= $first_part;
        } while (mb_strlen($value, 'utf-8') > $separate_line_after_chars);
        $final .= $returnes . "\n";
    }
    $text = $final;
    $width = $height = $offset_x = $offset_y = 0;
    $font = $_SERVER['DOCUMENT_ROOT'] . '/assets/css/journal.ttf';
    // get the font height.
    $bounds = ImageTTFBBox($size, $rotate, $font, "W");
    if ($rotate < 0) {
        $font_height = abs($bounds[7] - $bounds[1]);
    } elseif ($rotate > 0) {
        $font_height = abs($bounds[1] - $bounds[7]);
    } else {
        $font_height = abs($bounds[7] - $bounds[1]);
    }
    // determine bounding box.
    $bounds = ImageTTFBBox($size, $rotate, $font, $text);
    if ($rotate < 0) {
        $width = abs($bounds[4] - $bounds[0]);
        $height = abs($bounds[3] - $bounds[7]);
        $offset_y = $font_height;
        $offset_x = 0;
    } elseif ($rotate > 0) {
        $width = abs($bounds[2] - $bounds[6]);
        $height = abs($bounds[1] - $bounds[5]);
        $offset_y = abs($bounds[7] - $bounds[5]) + $font_height;
        $offset_x = abs($bounds[0] - $bounds[6]);
    } else {
        $width = abs($bounds[4] - $bounds[6]);
        $height = abs($bounds[7] - $bounds[1]);
        $offset_y = $font_height;
        $offset_x = 0;
    }
    $image = imagecreate($width + $padding * 2 + 1, $height + $padding * 2 + 1);
    $background = ImageColorAllocate($image, $bg_color['red'], $bg_color['grn'], $bg_color['blu']);
    $foreground = ImageColorAllocate($image, $color['red'], $color['grn'], $color['blu']);
    if ($transparent) {
        ImageColorTransparent($image, $background);
    }
    ImageInterlace($image, true);
    // render the image
    ImageTTFText($image, $size, $rotate, $offset_x + $padding, $offset_y + $padding, $foreground, $font, $text);
    imagealphablending($image, true);
    imagesavealpha($image, true);
    // output PNG object.
    imagePNG($image, 'signature.png');
    imagedestroy($image);
}
开发者ID:kevwaddell,项目名称:tlw-echosign,代码行数:59,代码来源:text-to-img.php

示例6: QrCode

 public function QrCode($assetId, $data, $display)
 {
     //split出display中的内容
     $displayArr = split('/', $display);
     $display = '编号:' . $displayArr[0] . PHP_EOL . '名称:' . $displayArr[1] . PHP_EOL . '型号:' . $displayArr[2];
     // 二维码数据
     // $data = 'helloworld';
     // 生成的文件名(路径)
     $codeTemp = 'qrCode/codeTemp.png';
     // 纠错级别:L、M、Q、H
     $errorCorrectionLevel = 'L';
     // 点的大小:1到10
     $matrixPointSize = 4;
     //创建一个二维码文件
     QRcode::png($data, $codeTemp, $errorCorrectionLevel, $matrixPointSize, 2);
     //输入二维码到浏览器
     //QRcode::png($data);
     //获取图片的宽高
     $size = getimagesize($codeTemp);
     $width = $size[0];
     $height = $size[1];
     //生成文本图片
     $textTemp = 'qrCode/textTemp.png';
     $im = imagecreate($width, 60);
     //图片的宽度高度
     $black = ImageColorAllocate($im, 255, 255, 2555);
     //背景颜色
     $white = ImageColorAllocate($im, 0, 0, 0);
     //字体颜色
     ImageTTFText($im, 10, 0, 10, 20, $white, "simhei.ttf", $display);
     imagepng($im, $textTemp);
     //图片拼接
     $bigphoto = $codeTemp;
     $footerphoto = $textTemp;
     $biginfo = getimagesize($bigphoto);
     $footerinfo = getimagesize($footerphoto);
     $bigwidth = $biginfo[0];
     $bigheight = $biginfo[1];
     $footerwidth = $footerinfo[0];
     $footerheight = $footerinfo[1];
     $initwidth = max(array($bigwidth, $footerwidth));
     $initheight = max(array($bigheight, $footerheight)) + min(array($bigheight, $footerheight));
     // header("Content-type: image/png");
     $im = imagecreatetruecolor($initwidth, $initheight);
     imagecopyresized($im, imagecreatefrompng($bigphoto), 0, 0, 0, 0, $bigwidth, $bigheight, $bigwidth, $bigheight);
     imagecopyresized($im, imagecreatefrompng($footerphoto), 0, $bigheight, 0, 0, $footerwidth, $footerheight, $footerwidth, $footerheight);
     $num = rand(0, 1000);
     // echo var_dump($num);
     $finalQRCode = "qrCode/finalQRCode" . $num . ".jpeg";
     // session_start();
     // $_SESSION["finalQRCode"]=$finalQRCode;
     imagepng($im, $finalQRCode);
     return $finalQRCode;
     // echo "<script language=\"JavaScript\">alert(\"添加成功\");</script>";
     // $this->render('add',array('type' => $type));
 }
开发者ID:jiahongwei,项目名称:newland-project,代码行数:56,代码来源:AssetManageController.php

示例7: _generate_image

 /**
  * Generates Image file for captcha
  *
  * @param string $location
  * @param string $char_seq
  * @return unknown
  */
 function _generate_image($location, $char_seq)
 {
     $num_chars = strlen($char_seq);
     $img = imagecreatetruecolor($this->width, $this->height);
     imagealphablending($img, 1);
     imagecolortransparent($img);
     // generate background of randomly built ellipses
     for ($i = 1; $i <= 200; $i++) {
         $r = round(rand(0, 100));
         $g = round(rand(0, 100));
         $b = round(rand(0, 100));
         $color = imagecolorallocate($img, $r, $g, $b);
         imagefilledellipse($img, round(rand(0, $this->width)), round(rand(0, $this->height)), round(rand(0, $this->width / 16)), round(rand(0, $this->height / 4)), $color);
     }
     $start_x = round($this->width / $num_chars);
     $max_font_size = $start_x;
     $start_x = round(0.5 * $start_x);
     $max_x_ofs = round($max_font_size * 0.9);
     // set each letter with random angle, size and color
     for ($i = 0; $i <= $num_chars; $i++) {
         $r = round(rand(127, 255));
         $g = round(rand(127, 255));
         $b = round(rand(127, 255));
         $y_pos = $this->height / 2 + round(rand(5, 20));
         $fontsize = round(rand(18, $max_font_size));
         $color = imagecolorallocate($img, $r, $g, $b);
         $presign = round(rand(0, 1));
         $angle = round(rand(0, 25));
         if ($presign == true) {
             $angle = -1 * $angle;
         }
         $fontpath = dirname(__FILE__) . '/';
         ImageTTFText($img, $fontsize, $angle, $start_x + $i * $max_x_ofs, $y_pos, $color, $fontpath . 'default.ttf', substr($char_seq, $i, 1));
     }
     // create image file
     imagejpeg($img, $location, $this->jpg_quality);
     chmod($location, 0777);
     flush();
     imagedestroy($img);
     // clean up
     $tmp_dir = dir($this->temp_dir);
     while ($entry = $tmp_dir->read()) {
         if (strpos($entry, 'cap_') !== false) {
             $del_file = $this->temp_dir . '/' . $entry;
             if (is_file($del_file)) {
                 if (time() - filemtime($del_file) > 360) {
                     //5 min
                     unlink($del_file);
                 }
             }
         }
     }
     return true;
 }
开发者ID:jrep20,项目名称:samcozen,代码行数:61,代码来源:class.captcha.php

示例8: draw

 function draw()
 {
     $width = 0;
     $height = 0;
     $offset_x = 0;
     $offset_y = 0;
     $bounds = array();
     $image = "";
     // get the font height.
     $bounds = ImageTTFBBox($this->size, $this->rot, $this->font, "W");
     if ($this->rot < 0) {
         $font_height = abs($bounds[7] - $bounds[1]);
     } else {
         if ($this->rot > 0) {
             $font_height = abs($bounds[1] - $bounds[7]);
         } else {
             $font_height = abs($bounds[7] - $bounds[1]);
         }
     }
     // determine bounding box.
     $bounds = ImageTTFBBox($this->size, $this->rot, $this->font, $this->msg);
     if ($this->rot < 0) {
         $width = abs($bounds[4] - $bounds[0]);
         $height = abs($bounds[3] - $bounds[7]);
         $offset_y = $font_height;
         $offset_x = 0;
     } else {
         if ($this->rot > 0) {
             $width = abs($bounds[2] - $bounds[6]);
             $height = abs($bounds[1] - $bounds[5]);
             $offset_y = abs($bounds[7] - $bounds[5]) + $font_height;
             $offset_x = abs($bounds[0] - $bounds[6]);
         } else {
             $width = abs($bounds[4] - $bounds[6]);
             $height = abs($bounds[7] - $bounds[1]);
             $offset_y = $font_height;
             $offset_x = 0;
         }
     }
     $image = imagecreate($width + $this->padX * 2 + 1, $height + $this->padY * 2 + 1);
     $background = ImageColorAllocate($image, $this->bg_red, $this->bg_grn, $this->bg_blu);
     $foreground = ImageColorAllocate($image, $this->red, $this->grn, $this->blu);
     if ($this->transparent) {
         ImageColorTransparent($image, $background);
     }
     ImageInterlace($image, false);
     // render the image
     ImageTTFText($image, $this->size, $this->rot, $offset_x + $this->padX, $offset_y + $this->padY, $foreground, $this->font, $this->msg);
     // output PNG object.
     imagePNG($image);
 }
开发者ID:pankajsinghjarial,项目名称:SYLC-AMERICAN,代码行数:51,代码来源:toImage.php

示例9: setimg

 public function setimg($img, $age, $gender, $score, $infos, $res, $skin, $huitou, $target, $types)
 {
     $dst = "/mnt/meilimei/m/upload/mojokbg.png";
     //得到原始图片信息
     $dst_im = imagecreatefrompng($dst);
     $dst_info = getimagesize($dst);
     //水印图像
     $src = "/mnt/meilimei/m/upload/mojokbg2.png";
     $src_im = imagecreatefrompng($src);
     $src_info = getimagesize($src);
     if ($types == 'image/png') {
         $im = imagecreatefrompng($img);
         //imagecreatefrompng
     } elseif ($types == 'image/jpeg') {
         $im = imagecreatefromjpeg($img);
     } elseif ($types == 'image/gif') {
         $im = imagecreatefromgif($img);
     } elseif ($types == 'image/bmp') {
         $im = imagecreatefromwbmp($img);
     }
     $im_src = getimagesize($img);
     $temp_img = imagecreatetruecolor(320, 480);
     //创建画布
     //$im=create($src);
     imagecopyresampled($temp_img, $im, 0, 0, 0, 0, 226, 313, $im_src[0], $im_src[1]);
     //人脸
     $alpha = 100;
     imagecopy($dst_im, $temp_img, 48, 75, 0, 0, 226, 313);
     //后人脸
     imagecopy($dst_im, $src_im, 45, 72, 0, 0, 237, 323);
     //背景
     //$im = imagecreate(400 , 300);
     $gray = ImageColorAllocate($dst_im, 255, 255, 255);
     $pink = ImageColorAllocate($dst_im, 246, 109, 152);
     $fontfilebold = "/mnt/meilimei/m/upload/msyhbd.ttf";
     $fontfile = "/mnt/meilimei/m/upload/msyh.ttf";
     $str = iconv('GB2312', 'UTF-8', $huitou . '%');
     $str1 = $infos;
     $str2 = iconv('GB2312', 'UTF-8', $skin);
     $str3 = iconv('GB2312', 'UTF-8', $score);
     $str4 = iconv('GB2312', 'UTF-8', $age);
     ImageTTFText($dst_im, 22, 0, 175, 40, $gray, $fontfilebold, $str);
     ImageTTFText($dst_im, 11, 0, 50, 65, $gray, $fontfile, $str1);
     ImageTTFText($dst_im, 19, 0, 67, 225, $pink, $fontfilebold, $str2);
     ImageTTFText($dst_im, 19, 0, 67, 273, $pink, $fontfilebold, $str3);
     ImageTTFText($dst_im, 19, 0, 67, 320, $pink, $fontfilebold, $str4);
     imagesavealpha($src_im, true);
     imagesavealpha($dst_im, true);
     Imagepng($dst_im, "/mnt/meilimei/m/upload/webmojing/" . date('Y') . '/' . date('m') . '/' . $target . ".jpg");
     return ImageDestroy($dst_im);
 }
开发者ID:sexseses,项目名称:meilimei_old_api,代码行数:51,代码来源:mojing.php

示例10: showImage

 function showImage()
 {
     $noise = true;
     $nb_noise = 10;
     $image = imagecreatetruecolor($this->height, $this->width);
     $width = imagesx($image);
     $height = imagesy($image);
     $back = ImageColorAllocate($image, intval(rand(224, 255)), intval(rand(224, 255)), intval(rand(224, 255)));
     ImageFilledRectangle($image, 0, 0, $width, $height, $back);
     if ($noise) {
         for ($i = 0; $i < $nb_noise; $i++) {
             $size = intval(rand(6, 14));
             $angle = intval(rand(0, 360));
             $x = intval(rand(10, $width - 10));
             $y = intval(rand(0, $height - 5));
             $color = imagecolorallocate($image, intval(rand(160, 224)), intval(rand(160, 224)), intval(rand(160, 224)));
             $text = chr(intval(rand(45, 250)));
             ImageTTFText($image, $size, $angle, $x, $y, $color, $this->get_font(), $this->code);
         }
         //$i = 0; $i < $nb_noise; $i++
     } else {
         for ($i = 0; $i < $width; $i += 10) {
             $color = imagecolorallocate($image, intval(rand(160, 224)), intval(rand(160, 224)), intval(rand(160, 224)));
             imageline($image, $i, 0, $i, $height, $color);
         }
         //$i = 0; $i < $width; $i += 10
         for ($i = 0; $i < $height; $i += 10) {
             $color = imagecolorallocate($image, intval(rand(160, 224)), intval(rand(160, 224)), intval(rand(160, 224)));
             imageline($image, 0, $i, $width, $i, $color);
         }
         //$i = 0; $i < $height; $i += 10
     }
     for ($i = 0, $x = 5; $i < strlen($this->code); $i++) {
         $r = intval(rand(0, 128));
         $g = intval(rand(0, 128));
         $b = intval(rand(0, 128));
         $color = ImageColorAllocate($image, $r, $g, $b);
         $shadow = ImageColorAllocate($image, $r + 128, $g + 128, $b + 128);
         $size = intval(rand(14, 19));
         $angle = intval(rand(-20, 20));
         $text = strtoupper(substr($this->code, $i, 1));
         ImageTTFText($image, $size, $angle, $x + 7, 26, $shadow, $this->get_font(), $text);
         ImageTTFText($image, $size - 1, $angle + 2, $x + 5, 24, $color, $this->get_font(), $text);
         $x += $size + 2;
     }
     //$i = 0, $x = 5; $i < strlen($this->code); $i++
     header('Content-type: image/jpeg');
     imagejpeg($image);
     ImageDestroy($image);
 }
开发者ID:sasha-adm-in,项目名称:project,代码行数:50,代码来源:captcham5.php

示例11: writeImage

function writeImage($width, $height, $strLen, $fontSize, $angMax, $font, $penColorRGB, $backColorRGB)
{
    $im = Imagecreate($width, $height);
    $backColorArray = explode(',', $backColorRGB);
    // Get RGB componenets
    // from string
    $penColorArray = explode(',', $penColorRGB);
    $backColor = imagecolorallocate($im, $backColorArray[0], $backColorArray[1], $backColorArray[2]);
    // allocate
    // color
    // for
    // background
    $penColor = imagecolorallocate($im, $penColorArray[0], $penColorArray[1], $penColorArray[2]);
    // allocate
    // color
    // for
    // writing
    $x = 20;
    // Start writing from $x with initial 20 pixels left blank
    $y = $fontSize + 20;
    $str = "";
    // Declaration just to avoid "undefined variable" warning
    for ($i = 0; $i <= $strLen - 1; $i++) {
        $chr = getRandChr();
        // Generate a random character
        $str .= "{$chr}";
        // Append to a string, for storing to SESSION
        $angle = rand(0, $angMax);
        // Set angle between 0 to $angMax
        if (rand(0, 1) == 0) {
            // Set Positive or Negative angle randomly
            $angle = -$angle;
        }
        ImageTTFText($im, $fontSize, $angle, $x, $y, $penColor, $font, $chr);
        $x = $x + 50;
        // Increment in x coordinate
    }
    $_SESSION['CaptchaCode'] = md5($str);
    // Assuming session is already
    // started, final CAPTCHA string
    // is stored in session
    header('Content-type: image/jpeg');
    // Set header
    imagejpeg($im);
    // produce jpeg image
    imagedestroy($im);
    // free-up temporary memory used to store image
}
开发者ID:K0smas,项目名称:Doulci-master,代码行数:48,代码来源:doulCiCaptcha.php

示例12: sumeCaptcha

 /**
  * Create a simple sume captcha
  */
 public function sumeCaptcha()
 {
     $val1 = rand(1, 9);
     $val2 = rand(1, 9);
     $result = $val1 + $vale;
     $txtCode = $val1 . ' + ' . $val2;
     $img = ImageCreateFromGIF('img/captcha/bg.gif');
     $bg = ImageColorAllocate($img, 240, 240, 240);
     $color = ImageColorAllocate($img, 0, 0, 0);
     $font = 'img/others/arial.ttf';
     // Create the Captcha image
     ImageTTFText($img, 20, 0, 13, 30, $color, $font, $txtCode);
     ImageJPEG($img, 'img/captcha/box.jpg', 75);
     ImageDestroy($img);
     return $result;
 }
开发者ID:kas-test,项目名称:framework,代码行数:19,代码来源:Captcha.php

示例13: draw

 public function draw()
 {
     $font = $this->_getFont();
     $htexte = 'dg' . $this->getText();
     $hdim = ImageTTFBBox($this->getSize(), 0, $font, $htexte);
     $wdim = ImageTTFBBox($this->getSize(), 0, $font, $this->getText());
     $dx = max($wdim[2], $wdim[4]) - min($wdim[0], $wdim[6]) + ceil($this->getSize() / 8);
     $dy = max($hdim[1], $hdim[3]) - min($hdim[5], $hdim[7]) + ceil($this->getSize() / 8);
     $img = ImageCreate(max($dx, 1), max($dy, 1));
     $noir = ImageColorAllocate($img, 0, 0, 0);
     $blanc = ImageColorAllocate($img, 255, 255, 255);
     $blanc = imagecolortransparent($img, $blanc);
     ImageFilledRectangle($img, 0, 0, $dx, $dy, $blanc);
     ImageTTFText($img, $this->getSize(), $angle, 0, -min($hdim[5], $hdim[7]), $noir, $font, $this->getText());
     return $img;
 }
开发者ID:nike-17,项目名称:formula-publish,代码行数:16,代码来源:Text.php

示例14: make_captcha

 function make_captcha($noise = true, $private_key, $fpath)
 {
     $font_file = JPATH_ROOT . DS . 'components' . DS . 'com_socialnetworking' . DS . 'assets' . DS . 'Dustismo.ttf';
     $image = imagecreatetruecolor(120, 30);
     $back = ImageColorAllocate($image, intval(rand(224, 255)), intval(rand(224, 255)), intval(rand(224, 255)));
     ImageFilledRectangle($image, 0, 0, 120, 30, $back);
     if ($noise) {
         // rand characters in background with random position, angle, color
         for ($i = 0; $i < 30; $i++) {
             $size = intval(rand(6, 14));
             $angle = intval(rand(0, 360));
             $x = intval(rand(10, 120 - 10));
             $y = intval(rand(0, 30 - 5));
             $color = imagecolorallocate($image, intval(rand(160, 224)), intval(rand(160, 224)), intval(rand(160, 224)));
             $text = chr(intval(rand(45, 250)));
             ImageTTFText($image, $size, $angle, $x, $y, $color, $font_file, $text);
         }
     } else {
         // random grid color
         for ($i = 0; $i < 120; $i += 10) {
             $color = imagecolorallocate($image, intval(rand(160, 224)), intval(rand(160, 224)), intval(rand(160, 224)));
             imageline($image, $i, 0, $i, 30, $color);
         }
         for ($i = 0; $i < 30; $i += 10) {
             $color = imagecolorallocate($image, intval(rand(160, 224)), intval(rand(160, 224)), intval(rand(160, 224)));
             imageline($image, 0, $i, 120, $i, $color);
         }
     }
     // private text to read
     for ($i = 0, $x = 5; $i < 6; $i++) {
         $r = intval(rand(0, 128));
         $g = intval(rand(0, 128));
         $b = intval(rand(0, 128));
         $color = ImageColorAllocate($image, $r, $g, $b);
         $shadow = ImageColorAllocate($image, $r + 128, $g + 128, $b + 128);
         $size = intval(rand(12, 17));
         $angle = intval(rand(-30, 30));
         $text = strtoupper(substr($private_key, $i, 1));
         ImageTTFText($image, $size, $angle, $x + 2, 26, $shadow, $font_file, $text);
         ImageTTFText($image, $size, $angle, $x, 24, $color, $font_file, $text);
         $x += $size + 2;
     }
     imagepng($image, $fpath);
     ImageDestroy($image);
 }
开发者ID:hrishikesh-kumar,项目名称:NBSNIP,代码行数:45,代码来源:socialnetworking.php

示例15: process

 function process()
 {
     global $CONFIG;
     $matches = array();
     if (!preg_match("/^([0-9a-zA-Z]+)\\.png\$/", $this->file, $matches)) {
         error_exit("Invalid image request for {$this->file}");
     }
     $code = $matches[1];
     $basepath = trim($CONFIG['paths']['base_url'], '/') . '/image/pins';
     $basefile = trim($CONFIG['paths']['file_path'], '/') . '/image/pins';
     $localfile = "{$basefile}/{$code}.png";
     if (file_exists($localfile)) {
         header("Location: http://{$_SERVER['HTTP_HOST']}/{$basepath}/{$code}.png");
     } else {
         if (!function_exists('ImageCreateFromPNG')) {
             header("Location: http://{$_SERVER['HTTP_HOST']}/{$basepath}/blank-marker.png");
         } else {
             $font = 'ttf-bitstream-vera/Vera';
             $size = 6;
             if (strlen($code) < 3) {
                 # Bigger image for number-only pins
                 $size = 8;
             }
             $im = ImageCreateFromPNG("{$basefile}/blank-marker.png");
             imageSaveAlpha($im, true);
             $tsize = ImageTTFBBox($size, 0, $font, $code);
             $textbg = ImageColorAllocate($im, 255, 119, 207);
             $black = ImageColorAllocate($im, 0, 0, 0);
             $dx = abs($tsize[2] - $tsize[0]);
             $dy = abs($tsize[5] - $tsize[3]);
             $x = (ImageSx($im) - $dx) / 2 + 1;
             $y = (ImageSy($im) - $dy) / 2;
             ImageTTFText($im, $size, 0, $x, $y, $black, $font, $code);
             header('Content-Type: image/png');
             ImagePNG($im);
             ImagePNG($im, $localfile);
             ImageDestroy($im);
         }
     }
     exit;
 }
开发者ID:roboshed,项目名称:leaguerunner,代码行数:41,代码来源:pins.php


注:本文中的ImageTTFText函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。