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


PHP imageCreate函数代码示例

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


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

示例1: create

 /**
  * 显示验证码
  */
 function create()
 {
     $this->image = imageCreate($this->width, $this->height);
     $this->back = $this->getColor($this->bgcolor);
     imageFilledRectangle($this->image, 0, 0, $this->width, $this->height, $this->back);
     $size = $this->width / $this->charLen - 4;
     if ($size > $this->height) {
         $size = $this->height;
     }
     $left = ($this->width - $this->charLen * ($size + $size / 10)) / $size + 5;
     $code = '';
     for ($i = 0; $i < $this->charLen; $i++) {
         $randKey = rand(0, count($this->arrChr) - 1);
         $randText = $this->arrChr[$randKey];
         $code .= $randText;
         $textColor = imageColorAllocate($this->image, rand(0, 100), rand(0, 100), rand(0, 100));
         $font = $this->fontPath . '/' . rand(1, 5) . ".ttf";
         $randsize = rand($size - $size / 10, $size + $size / 10);
         $location = $left + ($i * $size + $size / 10);
         @imagettftext($this->image, $randsize, rand(-18, 18), $location, rand($size - $size / 10, $size + $size / 10) + 2, $textColor, $font, $randText);
     }
     if ($this->showNoisePix == true) {
         $this->setNoisePix();
     }
     if ($this->showNoiseLine == true) {
         $this->setNoiseLine();
     }
     if ($this->showBorder == true) {
         $this->borderColor = $this->getColor($this->borderColor);
         imageRectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $this->borderColor);
     }
     $this->text = strtolower($code);
 }
开发者ID:beyondye,项目名称:ENPHP,代码行数:36,代码来源:Authcode.php

示例2: createEmptyImage

 /**
  * @see wcf\system\image\adapter\IImageAdapter::createEmptyImage()
  */
 public function createEmptyImage($width, $height)
 {
     $this->image = imageCreate($width, $height);
     $this->type = IMAGETYPE_PNG;
     $this->setColor(0xff, 0xff, 0xff);
     $this->color = null;
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:10,代码来源:GDImageAdapter.class.php

示例3: Graph

 function Graph($res)
 {
     if ($res == "svga") {
         $wd = "800";
         $ht = "600";
     } elseif ($res == "xga") {
         $wd = "1024";
         $ht = "768";
     } elseif ($res == "sxga") {
         $wd = "1280";
         $ht = "1024";
     } elseif ($res == "uxga") {
         $wd = "1600";
         $ht = "1200";
     } else {
         $wd = "640";
         $ht = "480";
     }
     $this->img = imageCreate($wd, $ht);
     $this->wte = imageColorAllocate($this->img, 255, 255, 255);
     $this->blk = imageColorAllocate($this->img, 0, 0, 0);
     $this->gry = imageColorAllocate($this->img, 100, 100, 100);
     $this->red = imageColorAllocate($this->img, 150, 0, 0);
     $this->grn = imageColorAllocate($this->img, 0, 150, 0);
     $this->blu = imageColorAllocate($this->img, 0, 0, 150);
     imagestring($this->img, 2, 5, 5, $res, $this->blu);
 }
开发者ID:pl0o0f,项目名称:nedi-puppet,代码行数:27,代码来源:libgraph.php

示例4: code39

 public static function code39($text, $height = 50, $widthScale = 1)
 {
     // if (!preg_match('/^[A-Z0-9-. $+\/%]+$/i', $text)) {
     //            throw new Exception('Invalid text input.');
     //        }
     // $text = '*' . strtoupper($text) . '*'; // *UPPERCASE TEXT*
     $length = strlen($text);
     $barcode = imageCreate($length * 16 * $widthScale, $height);
     $bg = imagecolorallocate($barcode, 255, 255, 255);
     //sets background to yellow
     imagecolortransparent($barcode, $bg);
     //makes that yellow transparent
     $black = imagecolorallocate($barcode, 0, 0, 0);
     //defines a color for black
     $chars = str_split($text);
     $colors = '';
     foreach ($chars as $char) {
         $colors .= self::$code39[$char];
     }
     foreach (str_split($colors) as $i => $color) {
         if ($color == 'b') {
             // imageLine($barcode, $i, 0, $i, $height-13, $black);
             //                imageFilledRectangle($barcode, $widthScale * $i, 0, $widthScale * ($i+1) -1 , $height-13, $black);
             imageFilledRectangle($barcode, $widthScale * $i, 0, $widthScale * ($i + 1) - 1, $height, $black);
         }
     }
     //16px per bar-set, halved, minus 6px per char, halved (5*length)
     // $textcenter = $length * 5 * $widthScale;
     //$textcenter = ($length * 8 * $widthScale) - ($length * 3);
     //
     //        imageString($barcode, 2, $textcenter, $height-13, $text, $black);
     header("Content-type: image/png");
     // out out the image
     imagepng($barcode);
 }
开发者ID:grissoft,项目名称:aviapochta,代码行数:35,代码来源:barcode.php

示例5: createImage

 public function createImage($text = '', $fontSize = 5)
 {
     // GD's built-in fonts are numbered from 1 - 5
     $font_size = $fontSize;
     // Calculate the appropriate image size
     $image_height = intval(imageFontHeight($font_size) * 2);
     $image_width = intval(strlen($text) * imageFontWidth($font_size) * 1.3);
     // Create the image
     $image = imageCreate($image_width, $image_height);
     // Create the colors to use in the image
     // gray background
     $back_color = imageColorAllocate($image, 216, 216, 216);
     // blue text
     $text_color = imageColorAllocate($image, 0, 0, 255);
     // black border
     $rect_color = imageColorAllocate($image, 0, 0, 0);
     // Figure out where to draw the text
     // (Centered horizontally and vertically
     $x = ($image_width - imageFontWidth($font_size) * strlen($text)) / 2;
     $y = ($image_height - imageFontHeight($font_size)) / 2;
     // Draw the text
     imageString($image, $font_size, $x, $y, $text, $text_color);
     // Draw a black border
     imageRectangle($image, 0, 0, imageSX($image) - 1, imageSY($image) - 1, $rect_color);
     // Send the image to the browser
     header('Content-Type: image/png');
     imagePNG($image);
     imageDestroy($image);
 }
开发者ID:puncoz,项目名称:presentation,代码行数:29,代码来源:images.php

示例6: 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

示例7: getCreateImage

 private function getCreateImage()
 {
     $this->image = imageCreate($this->width, $this->height);
     $background = imageColorAllocate($this->image, 255, 255, 255);
     $border = imageColorAllocate($this->image, 0, 0, 0);
     imageRectangle($this->image, 0, 0, $this->width - 1, $tihs->height - 1, $border);
 }
开发者ID:skyworld,项目名称:SKY_PHP,代码行数:7,代码来源:vcode.class.php

示例8: king_def

function king_def()
{
    global $king;
    header("Cache-Control: no-cache, must-revalidate");
    // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    // 过去的时间
    header("Content-type: image/png");
    $salt = kc_get('salt', 1, 1);
    $width = $king->config('verifywidth');
    //图片长度
    $height = $king->config('verifyheight');
    //图片高度
    $size = $king->config('verifysize');
    //文字大小
    $num = $king->config('verifynum');
    //文字数量
    $content = $king->config('verifycontent');
    //随机字符
    $array_content = explode('|', $content);
    $array_content = array_diff($array_content, array(null));
    $array_font = kc_f_getdir('system/verify_font', 'ttf|ttc');
    $str = '';
    $img = imageCreate($width, $height);
    //创建一个空白图像
    imageFilledRectangle($img, 0, 0, $width, $height, imagecolorallocate($img, 255, 255, 255));
    //写字
    for ($i = 0; $i < $num; $i++) {
        $code = $array_content[array_rand($array_content)];
        $str .= $code;
        //验证码字符
        $color = imageColorAllocate($img, rand(0, 128), rand(0, 128), rand(0, 128));
        $font = 'verify_font/' . $array_font[array_rand($array_font)];
        //随机读取一个字体
        $left = rand(round($size * 0.2), round($size * 0.4)) + $i * $size;
        imagettftext($img, rand(round($size * 0.7), $size), rand(-20, 20), $left, rand(round($size * 1.2), $size * 1.4), $color, $font, $code);
    }
    //画星号
    $max = $width * $height / 400;
    for ($i = 0; $i < $max; $i++) {
        imagestring($img, 15, rand(0, $width), rand(0, $height), '*', rand(192, 250));
    }
    //画点
    $max = $width * $height / 40;
    for ($i = 0; $i < $max; $i++) {
        imageSetPixel($img, rand(0, $width), rand(0, $height), rand(1, 200));
    }
    //画线
    $max = $width * $height / 800;
    for ($i = 0; $i < $max; $i++) {
        imageline($img, rand(0, $width), rand(0, $height), rand(0, $width), rand(0, $height), rand(0, 255));
    }
    //写验证码到verify中
    $verify = new KC_Verify_class();
    $verify->Put($salt, $str);
    imagePng($img);
    imageDestroy($img);
    $verify->Clear();
}
开发者ID:jonycookie,项目名称:projectm2,代码行数:59,代码来源:verify.php

示例9: getCreateImage

 private function getCreateImage()
 {
     //用来创建图像资源,并初使化背影
     $this->image = imageCreate($this->width, $this->height);
     $back = imageColorAllocate($this->image, 255, 255, 255);
     $border = imageColorAllocate($this->image, 0, 0, 0);
     imageRectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $border);
 }
开发者ID:soross,项目名称:myteashop,代码行数:8,代码来源:ValidationCode.php

示例10: writeCopy

 function writeCopy($filename, $width, $height) {
          if($this->isLoaded()) {
              $imageNew = imageCreate($width, $height);
              if(!$imageNew) {
                  echo "ERREUR : Nouvelle image non créée";
              }
              imageCopyResized($imageNew, $this->image, 0, 0, 0, 0, $width, $height, $this->width, $this->height);
              imageJpeg($imageNew, $filename);
          }
 }
开发者ID:nidtropical,项目名称:nidtropical_old,代码行数:10,代码来源:index.php

示例11: sendErrorImageAndDie

function sendErrorImageAndDie($cerr)
{
    $new = imageCreate(600, 30);
    $bgc = imageColorAllocate($new, 255, 255, 255);
    $tc = imageColorAllocate($new, 0, 0, 0);
    imageFilledRectangle($new, 0, 0, 150, 30, $bgc);
    imageString($new, 5, 5, 5, "Error: {$cerr}", $tc);
    sendImage($new);
    die;
}
开发者ID:adamisom,项目名称:chessimager,代码行数:10,代码来源:ChessImagerUtils.php

示例12: getCreateImage

 private function getCreateImage()
 {
     //创建指定大小的画布(基于调色板)
     $this->image = imageCreate($this->width, $this->height);
     //设置颜色(白色)
     $back = imagecolorallocate($this->image, 255, 255, 255);
     //设置颜色(黑色)
     $border = imagecolorallocate($this->image, 0, 0, 0);
     //在图像中绘制一个矩形
     imageRectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $border);
 }
开发者ID:yunsite,项目名称:t-info-together,代码行数:11,代码来源:ValidationCode.php

示例13: Generate

 function Generate($imgName)
 {
     //        $this->GenStr();
     $this->img = imageCreate(200, 50);
     $this->GenColors();
     $this->PutLetters();
     $this->PutEllipses();
     $this->PutLines();
     imagePNG($this->img, $imgName);
     return $this->strCheck;
 }
开发者ID:askovorodka,项目名称:sqc,代码行数:11,代码来源:captcha.class.php

示例14: create_avatar

function create_avatar($imgpath, $thumbpath, $neueBreite, $neueHoehe)
{
    $size = getimagesize($imgpath);
    $breite = $size[0];
    $hoehe = $size[1];
    $RatioW = $neueBreite / $breite;
    $RatioH = $neueHoehe / $hoehe;
    if ($RatioW < $RatioH) {
        $neueBreite = $breite * $RatioW;
        $neueHoehe = $hoehe * $RatioW;
    } else {
        $neueBreite = $breite * $RatioH;
        $neueHoehe = $hoehe * $RatioH;
    }
    $neueBreite = round($neueBreite, 0);
    $neueHoehe = round($neueHoehe, 0);
    if (function_exists('gd_info')) {
        $tmp = gd_info();
        $imgsup = $tmp['GIF Create Support'] ? 1 : 2;
        unset($tmp);
    } else {
        $imgsup = 2;
    }
    if ($size[2] < $imgsup or $size[2] > 3) {
        return false;
    }
    if ($size[2] == 1) {
        $altesBild = imagecreatefromgif($imgpath);
    } elseif ($size[2] == 2) {
        $altesBild = imagecreatefromjpeg($imgpath);
    } elseif ($size[2] == 3) {
        $altesBild = imagecreatefrompng($imgpath);
    }
    if (function_exists('imagecreatetruecolor') and $size[2] != 1) {
        $neuesBild = png_create_transparent($neueBreite, $neueHoehe);
        imagecopyresampled($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
    } elseif (function_exists('imagecreatetruecolor') and $size[2] == 1) {
        $neuesBild = imageCreate($neueBreite, $neueHoehe);
        gif_create_transparent($neuesBild, $altesBild);
        imagecopyresampled($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
    } else {
        $neuesBild = imageCreate($neueBreite, $neueHoehe);
        imageCopyResized($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
    }
    if ($size[2] == 1) {
        ImageGIF($neuesBild, $thumbpath);
    } elseif ($size[2] == 2) {
        ImageJPEG($neuesBild, $thumbpath);
    } elseif ($size[2] == 3) {
        ImagePNG($neuesBild, $thumbpath);
    }
    return true;
}
开发者ID:rjdesign,项目名称:Ilch-1.2,代码行数:53,代码来源:profile_image.php

示例15: show_emptyimg

 function show_emptyimg($format = 'gif')
 {
     header('Content-Type: image/' . $format);
     $width = 1;
     $height = 1;
     $img = imageCreate($width, $height);
     //imageFilledRectangle($img, 0, 0, $width, $height, imagecolorallocate($img, 255, 255, 255));
     ImageColorTransparent($img, imagecolorallocate($img, 255, 255, 255));
     imagegif($img);
     imagedestroy($img);
     exit;
 }
开发者ID:GavinLai,项目名称:SimMatch,代码行数:12,代码来源:fst.php


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