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


PHP imagefttext函数代码示例

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


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

示例1: generate

 /**
  * Saves avatar to DB and outputs that as PNG
  * @param int $id
  */
 public function generate($id)
 {
     $uid = (int) $id;
     $user = User::get($uid);
     $initial = strtoupper($user->username[0]);
     $bI = rand(0, 41);
     $color = $this->BACKGROUND_COLORS[$bI];
     $rgb = $this->hex2rgb($color);
     // Create a 300x100 image
     $im = imagecreatetruecolor(128, 128);
     $red = imagecolorallocate($im, $rgb[0], $rgb[1], $rgb[2]);
     $black = imagecolorallocate($im, 0xff, 0xff, 0xff);
     // Make the background red
     imagefilledrectangle($im, 0, 0, 128, 128, $red);
     // Path to our ttf font file
     $font_file = ASSET_DIR . 'img/general/SourceCodePro-Light.ttf';
     // Draw the text 'PHP Manual' using font size 13
     imagefttext($im, 80, 0, 32, 100, $black, $font_file, $initial);
     // Output image to the browser
     header('Content-Type: image/png');
     $name = $initial . '_' . str_replace('#', '', $color) . '.png';
     imagepng($im, AVATAR_PATH . $name);
     $resizer = new \Ext\ImageResize();
     $iconW = 36;
     $iconH = 36;
     $iconPath = AVATAR_PATH . 'icons/' . $name;
     $success = $resizer->smart_resize_image(AVATAR_PATH . $name, NULL, $iconW, $iconH, true, $iconPath, FALSE, FALSE, 75);
     if (!$success) {
         @copy(AVATAR_PATH . $name, $iconPath);
     }
     $user->set(array('avatar' => $name));
     imagepng($im);
     imagedestroy($im);
 }
开发者ID:kertkulp,项目名称:php-ruhmatoo-projekt,代码行数:38,代码来源:Avatar.php

示例2: render

 /**
  * Outputs the Captcha image.
  *
  * @param   boolean  html output
  * @return  mixed
  */
 public function render($html)
 {
     // Creates a black image to start from
     $this->image_create(Captcha::$config['background']);
     // Add random white/gray arcs, amount depends on complexity setting
     $count = (Captcha::$config['width'] + Captcha::$config['height']) / 2;
     $count = $count / 5 * min(10, Captcha::$config['complexity']);
     for ($i = 0; $i < $count; $i++) {
         imagesetthickness($this->image, mt_rand(1, 2));
         $color = imagecolorallocatealpha($this->image, 255, 255, 255, mt_rand(0, 120));
         imagearc($this->image, mt_rand(-Captcha::$config['width'], Captcha::$config['width']), mt_rand(-Captcha::$config['height'], Captcha::$config['height']), mt_rand(-Captcha::$config['width'], Captcha::$config['width']), mt_rand(-Captcha::$config['height'], Captcha::$config['height']), mt_rand(0, 360), mt_rand(0, 360), $color);
     }
     // Use different fonts if available
     $font = Captcha::$config['fontpath'] . Captcha::$config['fonts'][array_rand(Captcha::$config['fonts'])];
     // Draw the character's white shadows
     $size = (int) min(Captcha::$config['height'] / 2, Captcha::$config['width'] * 0.8 / strlen($this->response));
     $angle = mt_rand(-15 + strlen($this->response), 15 - strlen($this->response));
     $x = mt_rand(1, Captcha::$config['width'] * 0.9 - $size * strlen($this->response));
     $y = (Captcha::$config['height'] - $size) / 2 + $size;
     $color = imagecolorallocate($this->image, 255, 255, 255);
     imagefttext($this->image, $size, $angle, $x + 1, $y + 1, $color, $font, $this->response);
     // Add more shadows for lower complexities
     Captcha::$config['complexity'] < 10 and imagefttext($this->image, $size, $angle, $x - 1, $y - 1, $color, $font, $this->response);
     Captcha::$config['complexity'] < 8 and imagefttext($this->image, $size, $angle, $x - 2, $y + 2, $color, $font, $this->response);
     Captcha::$config['complexity'] < 6 and imagefttext($this->image, $size, $angle, $x + 2, $y - 2, $color, $font, $this->response);
     Captcha::$config['complexity'] < 4 and imagefttext($this->image, $size, $angle, $x + 3, $y + 3, $color, $font, $this->response);
     Captcha::$config['complexity'] < 2 and imagefttext($this->image, $size, $angle, $x - 3, $y - 3, $color, $font, $this->response);
     // Finally draw the foreground characters
     $color = imagecolorallocate($this->image, 0, 0, 0);
     imagefttext($this->image, $size, $angle, $x, $y, $color, $font, $this->response);
     // Output
     return $this->image_render($html);
 }
开发者ID:momoim,项目名称:momo-api,代码行数:39,代码来源:Black.php

示例3: generate_image

 function generate_image($canvas)
 {
     global $captcha_font_path, $captcha_img_path;
     $hit = "Считай детерминант!";
     $a = rand(1, 9);
     $b = rand(1, 9);
     $c = rand(1, 9);
     $d = rand(1, 9);
     $color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
     imageline($canvas, 20, 10, 20, 60, $color);
     imageline($canvas, 160, 10, 160, 60, $color);
     $rand = " =?";
     for ($i = 0; $i < strlen($rand); $i++) {
         $color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
         imagefttext($canvas, 20, rand(-45, 45), 144 + 20 * $i, 50, $color, $captcha_font_path . "/LiberationMono-Bold.ttf", $rand[$i]);
     }
     $color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
     imagefttext($canvas, 20, rand(-5, 5), 40, 20, $color, $captcha_font_path . "/LiberationMono-Bold.ttf", $a);
     imagefttext($canvas, 20, rand(-5, 5), 40, 50, $color, $captcha_font_path . "/LiberationMono-Bold.ttf", $b);
     imagefttext($canvas, 20, rand(-5, 5), 120, 20, $color, $captcha_font_path . "/LiberationMono-Bold.ttf", $c);
     imagefttext($canvas, 20, rand(-5, 5), 120, 50, $color, $captcha_font_path . "/LiberationMono-Bold.ttf", $d);
     imagefttext($canvas, 11, rand(-5, 5), 15, 75, $color, $captcha_font_path . "/LiberationMono-Bold.ttf", $hit);
     $nme = $this->ucaptcha->get_filename();
     //imagepng($canvas,$captcha_img_path."/".$nme.".png");
     imagepng($canvas);
     $ans = $a * $d - $b * $c;
     $captcha[0] = $nme;
     $captcha[1] = $ans;
     return $captcha;
 }
开发者ID:vladimir-g,项目名称:rulinux-engine,代码行数:30,代码来源:plugin.php

示例4: msg

function msg($msg)
{
    $container = imagecreate(250, 170);
    //SET SIZE OF IMAGE
    $black = imagecolorallocate($container, 0, 0, 0);
    //set RGB for black
    $white = imagecolorallocate($container, 255, 255, 255);
    //set RGB for white
    $font = '/Library/Fonts/Arial.ttf';
    //grab the font from my harddrive
    imagefilledrectangle($container, 0, 0, 250, 170, $black);
    // crate rectangle graphic
    $px = imagesx($container) / (strlen($msg) / 1.15);
    // x axis position
    $py = imagesy($container) / 3.5;
    // ;y axis position
    // Write text to the image using fonts using FreeType 2
    imagefttext($container, 28, -27, $px, $py, $white, $font, $msg);
    header("Content-type: image/png");
    // Change header type
    imagepng($container, null);
    // Output a png image to either the browser or a file
    imagedestroy($container);
    // Frees any memory associated with the image
}
开发者ID:jnashsiegle,项目名称:SSL,代码行数:25,代码来源:captcha.php

示例5: vCode

function vCode($num = 4, $size = 20, $width = 0, $height = 0)
{
    !$width && ($width = $num * $size * 4 / 5 + 5);
    !$height && ($height = $size + 10);
    $str = "0123456789";
    //验证码字符全集
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    // 画图像
    $im = imagecreatetruecolor($width, $height);
    // 定义要用到的颜色
    $back_color = imagecolorallocate($im, 255, 255, 255);
    //    $boer_color = imagecolorallocate($im, 100, 100, 100);
    $text_color = imagecolorallocate($im, 50, 50, 50);
    // 画背景
    imagefilledrectangle($im, 0, 0, $width, $height, $back_color);
    // 画边框
    //    imagerectangle($im, 0, 0, $width-1, $height-1, $boer_color);
    // 画干扰线
    for ($i = 0; $i < 30; $i++) {
        $font_color = imagecolorallocate($im, 0, 0, 0);
        imagearc($im, mt_rand(-$width, $width), mt_rand(-$height, $height), mt_rand(30, $width * 2), mt_rand(20, $height * 2), mt_rand(0, 360), mt_rand(0, 360), $font_color);
    }
    // 画验证码
    @imagefttext($im, $size, 0, 5, $size + 3, $text_color, 'images/index/Callie-Mae.ttf', $code);
    $_SESSION["VerifyCode"] = $code;
    header("Cache-Control: max-age=1, s-maxage=1, no-cache, must-revalidate");
    header("Content-type: image/png;charset=gb2312");
    imagepng($im);
    imagedestroy($im);
}
开发者ID:xiaoshizhishijingsai,项目名称:2014,代码行数:33,代码来源:identify.php

示例6: genImage

 public function genImage()
 {
     // text to be printed
     if (!$this->value) {
         $this->value = $this->genValue();
     }
     $chars = mb_strlen($this->value, "utf8");
     // create canvas
     $image = imagecreatetruecolor($this->config["width"], $this->config["height"]);
     $bg = imagecolorallocate($image, $this->config["background"][0], $this->config["background"][1], $this->config["background"][2]);
     $fg = imagecolorallocate($image, $this->config["color"][0], $this->config["color"][1], $this->config["color"][2]);
     imagefill($image, $this->config["width"] / 2, $this->config["height"] / 2, $bg);
     // font size
     if ($this->config["minfont"] == "auto") {
         $fsmin = min($this->config["width"] / ($chars + 1), $this->config["height"]);
     } else {
         $fsmin = $this->config["minfont"];
     }
     if ($this->config["maxfont"] == "auto") {
         $fsmax = min($this->config["width"] / ($chars + 1), $this->config["height"]);
     } else {
         $fsmax = $this->config["maxfont"];
     }
     // Padding - offset of the text
     $xStart = -$fsmax / 2;
     $xEnd = $this->config["width"];
     $yStart = $this->config["height"] * 0.6;
     $yEnd = $this->config["height"] * 0.8;
     // angle
     $angle = mt_rand(-15, 15);
     // print chars
     for ($i = 0; $i < $chars; $i++) {
         $angle += mt_rand(-3, 3);
         $xStart += $fsmax;
         imagefttext($image, mt_rand($fsmin, $fsmax), $angle, $xStart, mt_rand($yStart, $yEnd), $fg, $this->config["font"], mb_substr($this->value, $i, 1, "utf8"));
     }
     // Add some noise to the image.
     if ($this->config["noise"]) {
         for ($i = 0; $i < $this->config["noise"]; $i++) {
             $color = imagecolorallocate($image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
             for ($j = 0; $j < $this->config["width"] * $this->config["height"] / 100; $j++) {
                 imagesetpixel($image, mt_rand(0, $this->config["width"]), mt_rand(0, $this->config["height"]), $color);
             }
         }
     }
     // blur image
     if ($this->config["blur"]) {
         imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR);
     }
     // send image
     if ($this->config["format"] == "png") {
         header("Content-type: image/png");
         imagepng($image);
     } else {
         header("Content-type: image/jpeg");
         imagejpeg($image, null, 80);
     }
     imagedestroy($image);
     //return $image;
 }
开发者ID:rezon,项目名称:sugi,代码行数:60,代码来源:Captcha.php

示例7: generateImage

 function generateImage(&$captcha)
 {
     $width = $this->getWidth();
     $height = $this->getHeight();
     $length = String::strlen($captcha->getValue());
     $value = $captcha->getValue();
     $image = imagecreatetruecolor($width, $height);
     $fg = imagecolorallocate($image, rand(128, 255), rand(128, 255), rand(128, 255));
     $bg = imagecolorallocate($image, rand(0, 64), rand(0, 64), rand(0, 64));
     imagefill($image, $width / 2, $height / 2, $bg);
     $xStart = rand($width / 12, $width / 3);
     $xEnd = rand($width * 2 / 3, $width * 11 / 12);
     for ($i = 0; $i < $length; $i++) {
         imagefttext($image, rand(20, 34), rand(-15, 15), $xStart + ($xEnd - $xStart) * $i / $length + rand(-5, 5), rand(40, 60), $fg, Config::getVar('captcha', 'font_location'), String::substr($value, $i, 1));
     }
     // Add some noise to the image.
     for ($i = 0; $i < 20; $i++) {
         $color = imagecolorallocate($image, rand(0, 255), rand(0, 255), rand(0, 255));
         for ($j = 0; $j < 20; $j++) {
             imagesetpixel($image, rand(0, $this->getWidth()), rand(0, $this->getHeight()), $color);
         }
     }
     header('Content-type: ' . $this->getMimeType());
     imagepng($image);
     imagedestroy($image);
 }
开发者ID:LiteratimBi,项目名称:jupitertfn,代码行数:26,代码来源:CaptchaManager.inc.php

示例8: refresh

 /**
  * @param Thumbnail $thumbnail
  * @return void
  * @throws Exception\NoThumbnailAvailableException
  */
 public function refresh(Thumbnail $thumbnail)
 {
     $temporaryPathAndFilename = null;
     try {
         $filename = pathinfo($thumbnail->getOriginalAsset()->getResource()->getFilename(), PATHINFO_FILENAME);
         $temporaryLocalCopyFilename = $thumbnail->getOriginalAsset()->getResource()->createTemporaryLocalCopy();
         $temporaryPathAndFilename = $this->environment->getPathToTemporaryDirectory() . uniqid('ProcessedFontThumbnail-') . '.' . $filename . '.jpg';
         $width = 1000;
         $height = 1000;
         $im = imagecreate($width, $height);
         $red = imagecolorallocate($im, 0xff, 0xff, 0xff);
         $black = imagecolorallocate($im, 0x0, 0x0, 0x0);
         imagefilledrectangle($im, 0, 0, 1000, 1000, $red);
         imagefttext($im, 48, 0, 80, 150, $black, $temporaryLocalCopyFilename, 'Neos Font Preview');
         imagefttext($im, 32, 0, 80, 280, $black, $temporaryLocalCopyFilename, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
         imagefttext($im, 32, 0, 80, 360, $black, $temporaryLocalCopyFilename, 'abcdefghijklmopqrstuvwxyz');
         imagefttext($im, 32, 0, 80, 440, $black, $temporaryLocalCopyFilename, '1234567890');
         imagefttext($im, 32, 0, 80, 560, $black, $temporaryLocalCopyFilename, '+ " * ç % & / ( ) = ? @ €');
         imagejpeg($im, $temporaryPathAndFilename);
         $resource = $this->resourceManager->importResource($temporaryPathAndFilename);
         $processedImageInfo = $this->resize($thumbnail, $resource);
         $thumbnail->setResource($processedImageInfo['resource']);
         $thumbnail->setWidth($processedImageInfo['width']);
         $thumbnail->setHeight($processedImageInfo['height']);
         Files::unlink($temporaryPathAndFilename);
     } catch (\Exception $exception) {
         Files::unlink($temporaryPathAndFilename);
         $filename = $thumbnail->getOriginalAsset()->getResource()->getFilename();
         $sha1 = $thumbnail->getOriginalAsset()->getResource()->getSha1();
         $message = sprintf('Unable to generate thumbnail for the given font (filename: %s, SHA1: %s)', $filename, $sha1);
         throw new Exception\NoThumbnailAvailableException($message, 1433109653, $exception);
     }
 }
开发者ID:mgoldbeck,项目名称:neos-development-collection,代码行数:38,代码来源:FontDocumentThumbnailGenerator.php

示例9: nameToImage

 private function nameToImage()
 {
     $fontcolor = imagecolorallocate($this->image, $this->fontcolor_red, $this->fontcolor_green, $this->fontcolor_blue);
     if (preg_match("/^([0-9a-zA-Z_]|[[:punct:]])\$/", $this->name_arr, $this->matches)) {
         imagefttext($this->image, $this->img_width * 0.52, 0, $this->img_width * 0.33, $this->img_width * 0.7, $fontcolor, $this->font_file, $this->matches[0]);
     } else {
         imagefttext($this->image, $this->img_width * 0.52, 0, $this->img_width * 0.17, $this->img_width * 0.73, $fontcolor, $this->font_file, $this->name_arr);
     }
 }
开发者ID:DoctorAlien,项目名称:CreatePortrait-PHP,代码行数:9,代码来源:portrait.class.php

示例10: makeImage

 private function makeImage()
 {
     $achievement = imagecreatefrompng($this->background);
     imagesavealpha($achievement, true);
     imagecopyresampled($achievement, $this->iconImage, 16, 16, 0, 0, 32, 32, 32, 32);
     imagefttext($achievement, 12, 0, 60, 28, imagecolorallocate($achievement, 255, 255, 0), $this->font, $this->topText);
     imagefttext($achievement, 12, 0, 60, 50, imagecolorallocate($achievement, 255, 255, 255), $this->font, $this->bottomText);
     //imagefttext($achievement, 6, 0, 10, 57, imagecolorallocate($achievement, 255, 255, 0), $this->font, "achievecraft.net");
     return $achievement;
 }
开发者ID:xmx1024,项目名称:AchieveCraft,代码行数:10,代码来源:Achievement.class.php

示例11: mkCode

 public function mkCode($num = 4, $size = 20, $width = 0, $height = 0)
 {
     // $num => 验证码字符数目
     // $size => 字符大小(注意单位是pt不是px)
     // $width这只是大概的图像宽度,因为不同字体的同样font-size所占width也是有微小差距的
     !$width && ($width = $num * $size);
     //根据要显示验证码字符长度设置验证码图像长度
     !$height && ($height = $size + 10);
     //设置图像的高度
     $font_url = dirname(dirname(__FILE__)) . "/font/mywanderingheart.ttf";
     //如果字体路径错误:会无法显示验证码,但是有图像(后面这一点得看情况)
     // 我们要显示的验证码字符集合
     $str = "23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVW";
     //要显示的验证码
     $code = '';
     for ($i = 0; $i < $num; $i++) {
         $code .= $str[mt_rand(0, strlen($str) - 1)];
     }
     // 画图像,新建一个真彩色图像,并返回一个图像标识符赋值给 $im
     $im = imagecreatetruecolor($width, $height);
     // 定义要用到的颜色
     $background_color = imagecolorallocate($im, 255, 255, 255);
     //这里默认白色背景
     $border_color = imagecolorallocate($im, 255, 255, 255);
     //这里默认白色边框
     $text_color = imagecolorallocate($im, 50, 50, 50);
     //这里默认淡黑色字体颜色
     // 画背景
     imagefilledrectangle($im, 0, 0, $width, $height, $background_color);
     // 画边框(该函数事实上是画一个矩形)
     imagerectangle($im, 0, 0, $width - 1, $height - 1, $border_color);
     // 画干扰点
     for ($i = 0; $i < 10 * $num; $i++) {
         $font_color = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagesetpixel($im, mt_rand(0, $width), mt_rand(0, $height), $font_color);
     }
     // 默认画4条干扰线
     //这地方可以自己研究一下
     for ($i = 0; $i < 4; $i++) {
         $font_color = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagearc($im, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, 360), mt_rand(0, 360), $font_color);
         // imagearc($im, 0, 0, $width*2, $height, 0, 90, $font_color);
     }
     //好吧,是时候把验证码字符画上去了
     @imagefttext($im, $size, 0, 10, $size + 5, $text_color, $font_url, $code);
     // 喂,浏览器!我给你发的这个东西不要从你的缓存中拿啊。还有啊,这是一个png图像,不要解析错了。
     header("Cache-Control: max-age=1, s-maxage=1, no-cache, must-revalidate");
     header("Content-type: image/png;charset=utf-8");
     // imagepng 以 PNG 格式将图像输出到浏览器,如果指定了第二个参数 filename 将保存图像到文件
     // 例如imagepng( $im, '1.png' ); 将图像保存到同级目录下的1.png文件(如果该文件已存在则覆盖)
     imagepng($im);
     imagedestroy($im);
     return $code;
     //把验证码字符返回
 }
开发者ID:AJLoveChina,项目名称:PHPVerifyCode,代码行数:55,代码来源:class.php

示例12: msg

 public function msg($msg)
 {
     $container = imagecreatefromjpeg('images/captcha_bg.jpg');
     $black = imagecolorallocate($container, 0, 0, 0);
     //$white = imagecolorallocate($container,255,255,255);
     $font = 'fonts/acce.ttf';
     imagerectangle($container, 0, 0, 200, 100, $black);
     imagefttext($container, 24, 0, 22, 62, $black, $font, $msg);
     //can make a randomizer
     imagepng($container, 'images/newCaptcha.jpg');
     imagedestroy($container);
 }
开发者ID:richardHutchinson,项目名称:ssl,代码行数:12,代码来源:Image.php

示例13: make

 public static function make($is_text = 'no')
 {
     global $uri;
     // $db1=array('so','feel','catch','great','well','type','run','fast','call','like','hot','cold','cool','can','write','read','speed');
     // $db2=array('me','what','baby','care','rank','park','summer','katy');
     // shuffle($db1);
     // shuffle($db2);
     $main_img = imagecreatetruecolor(250, 78);
     $bg_color = imagecolorallocate($main_img, 255, 255, 255);
     imagefill($main_img, 0, 0, $bg_color);
     $captcha_str = String::randNumber(6);
     // $captcha_str = $db1[0] . ' ' . $db2[0];
     $dbColor = array(0 => array(100, 161, 39), 1 => array(64, 64, 64), 2 => array(65, 192, 209), 3 => array(237, 89, 26), 4 => array(237, 26, 72), 5 => array(163, 39, 161), 6 => array(78, 207, 96), 7 => array(219, 24, 157));
     $dbRotator = array(45, 10, 30, -5, -10, -30, -50);
     $dbUpDown = array(55, 40, 50, 45, 35, 30, 65);
     $font_file = ROOT_PATH . 'uploads/Eirik Raude.ttf';
     $strLen = strlen($captcha_str);
     $space = 20;
     for ($i = 0; $i < $strLen; $i++) {
         $colorRand = rand(0, 7);
         $rotatorRand = rand(0, 5);
         $updownRand = rand(0, 3);
         $black = imagecolorallocate($main_img, $dbColor[$colorRand][0], $dbColor[$colorRand][1], $dbColor[$colorRand][2]);
         imagefttext($main_img, 30, $dbRotator[$rotatorRand], $space, $dbUpDown[$updownRand], $black, $font_file, $captcha_str[$i]);
         $space += 20;
     }
     //        $colorRand = rand(0, 7);
     //
     //        $black = imagecolorallocate($main_img, $dbColor[$colorRand][0], $dbColor[$colorRand][1], $dbColor[$colorRand][2]);
     //
     //        imagefttext($main_img, 30, 0, 15, 55, $black, $font_file, $captcha_str);
     //        Create session
     $hash = md5($captcha_str);
     //        self::$thisHash=$hash;
     if (!isset($_SESSION['captcha'])) {
         $_SESSION['captcha'] = array();
     }
     $_SESSION['captcha'][$hash] = 'OK';
     //        End create session
     if ($is_text == 'no') {
         header("Content-type: image/png");
         imagepng($main_img);
     } else {
         $savePath = ROOT_PATH . 'uploads/' . String::randAlpha(12) . '.png';
         imagepng($main_img, $savePath);
         //            $dataImg = ob_get_contents();
         //            ob_end_clean();
         $dataImg = file_get_contents($savePath);
         unlink($savePath);
         return 'data:image/png;base64,' . base64_encode($dataImg);
     }
 }
开发者ID:neworldwebsites,项目名称:noblessecms,代码行数:52,代码来源:Captcha.php

示例14: render

 /**
  * @param resource &$objResource
  *
  * @return bool
  */
 public function render(&$objResource)
 {
     $strFontPath = class_resourceloader::getInstance()->getPathForFile("/system/fonts/" . $this->strFont);
     if ($strFontPath !== false && is_file(_realpath_ . $strFontPath)) {
         $intColor = $this->allocateColor($objResource, $this->arrColor);
         $strText = html_entity_decode($this->strText, ENT_COMPAT, "UTF-8");
         imagealphablending($objResource, true);
         imagefttext($objResource, $this->floatSize, $this->floatAngle, $this->intX, $this->intY, $intColor, _realpath_ . $strFontPath, $strText);
         imagealphablending($objResource, false);
         return true;
     }
     return false;
 }
开发者ID:jinshana,项目名称:kajonacms,代码行数:18,代码来源:class_image_text.php

示例15: text2image

function text2image($height, $text)
{
header("Content-type: image/png");
$width = $height * strlen($text)/ 5 * 2;
$font = "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf";
$image = imageCreate($width, $height);
$backgroundColor = imageColorAllocate($image, 255, 255, 255);
$textColor = imageColorAllocate($image, 0, 0, 0);
imagefttext($image, $height/2, 0, 0, $height/10*9, $textColor, $font, $text); 
imageInterlace($image, 1);
imageColorTransparent($image, $backgroundColor);
imagePNG($image);
}
开发者ID:pier22,项目名称:Band-Page-FB,代码行数:13,代码来源:text2image.php


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