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


PHP ImagePng函数代码示例

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


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

示例1: text2etc

function text2etc($text, $CP, $mode = "png", $trans = 1)
{
    global $TTF_LOCATION, $FONT_SIZE;
    //$outputtext = implode('',file($f));
    $outputtext = $text;
    $outputtext = Conv2UTF8($outputtext, 1, $CP);
    $outputtext = str_replace("\r\n", "\n", $outputtext);
    $outputtext = str_replace("\r", "\n", $outputtext);
    $outputtext = str_replace("\n", "\r\n", $outputtext);
    $outputtext = str_replace("<br />", "\r\n", $outputtext);
    $outputtext = str_replace("&nbsp;", " ", $outputtext);
    $outputtext = unhtmlentities($outputtext);
    if ($mode == "png") {
        $dim = imageftbbox($FONT_SIZE, 0, $TTF_LOCATION, $outputtext, array("linespacing" => 1.0));
        #		$dim= imagettfbbox($FONT_SIZE, 0, $TTF_LOCATION, $outputtext);
        $min_x = min($dim[0], $dim[2], $dim[4], $dim[6]);
        $max_x = max($dim[0], $dim[2], $dim[4], $dim[6]);
        $width = $max_x - $min_x + 1;
        $min_y = min($dim[1], $dim[3], $dim[5], $dim[7]);
        $max_y = max($dim[1], $dim[3], $dim[5], $dim[7]);
        $height = $max_y - $min_y + 1;
        $img = imagecreate($width + 1, $height + 1);
        $white = ImageColorAllocate($img, 255, 255, 255);
        if ($trans) {
            $twhite = imagecolortransparent($img, $white);
        }
        $black = ImageColorAllocate($img, 0, 0, 0);
        #		ImageTTFText($img, $FONT_SIZE, 0, -$min_x+$dim[0],-$min_y, $black, $TTF_LOCATION, $outputtext);
        ImageFTText($img, $FONT_SIZE, 0, -$min_x + $dim[0], -$min_y, $black, $TTF_LOCATION, $outputtext, array("linespacing" => 1.0));
        Header("Content-type: image/png");
        ImagePng($img);
        ImageDestroy($img);
    } else {
        if ($mode == "pre") {
            echo "<pre>\n{$outputtext}\n</pre>";
        } else {
            if ($mode == "text") {
                Header("Content-type: text/plain");
                echo utf8Encode($outputtext);
            }
        }
    }
}
开发者ID:h16o2u9u,项目名称:rtoss,代码行数:43,代码来源:txtrender.php

示例2: init_resultat_election

function init_resultat_election()
{
    global $image, $blanc, $noir, $gris, $gris2;
    header("Content-type: image/png");
    $annee = $_REQUEST[annee];
    $genre = $_REQUEST[genre];
    $type = $_REQUEST[type];
    $lesMiss = selectDbMiss($annee, $genre, $type, "", true);
    usort($lesMiss, "callback_sort_nb_votes");
    $nb = count($lesMiss);
    $hauteur = TAILLE_BARRE * $nb;
    $largeur = TAILLE_HAUTEUR;
    $image = ImageCreate($hauteur, $largeur);
    // On passe en blanc le fond de l'image
    $blanc = imagecolorallocate($image, 255, 255, 255);
    $noir = imagecolorallocate($image, 0, 0, 0);
    $gris = ImageColorAllocate($image, 190, 190, 190);
    $gris2 = ImageColorAllocate($image, 140, 140, 140);
    imagefilledrectangle($image, 0, 0, $largeur, $hauteur, $blanc);
    $total_votes = nombre_votes_db($annee, $genre, $type);
    dessine_nom_results_miss($lesMiss, $total_votes);
    // Génération de l'image
    ImagePng($image);
    // Desctruction de l'image
    ImageDestroy($image);
}
开发者ID:relaismago,项目名称:outils,代码行数:26,代码来源:resultats_miss_img.php

示例3: display

 /**
 * $IMG_WIDTH = 100; //图像宽度
 		$IMG_HEIGHT = 23; //图像高度
 		$SESSION_VDCODE = ''; //Session变量名称
 * $operator =  '+-'; //运算符
 */
 public static function display($IMG_WIDTH = 70, $IMG_HEIGHT = 25, $SESSION_VDCODE = 'vdcode', $operator = '+')
 {
     $session_id = session_id();
     if (empty($session_id)) {
         @session_start();
     }
     $code = array();
     $num1 = $code[] = mt_rand(1, 9);
     $code[] = '+';
     //{mt_rand(0,1)};
     $num2 = $code[] = mt_rand(1, 9);
     $codestr = implode('', $code);
     //eval("\$result = ".implode('',$code).";");
     $code[] = '=';
     $_SESSION[$SESSION_VDCODE] = (int) $num1 + (int) $num2;
     $img = ImageCreate($IMG_WIDTH, $IMG_HEIGHT);
     ImageColorAllocate($img, mt_rand(230, 250), mt_rand(230, 250), mt_rand(230, 250));
     $color = ImageColorAllocate($img, 0, 0, 0);
     $offset = 0;
     foreach ($code as $char) {
         $offset += 15;
         $txtcolor = ImageColorAllocate($img, mt_rand(0, 255), mt_rand(0, 150), mt_rand(0, 255));
         ImageChar($img, mt_rand(3, 5), $offset, mt_rand(1, 5), $char, $txtcolor);
     }
     for ($i = 0; $i < 100; $i++) {
         $pxcolor = ImageColorAllocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         ImageSetPixel($img, mt_rand(0, $IMG_WIDTH), mt_rand(0, $IMG_HEIGHT), $pxcolor);
     }
     header('Content-type: image/png');
     ImagePng($img);
     exit;
 }
开发者ID:ahmatjan,项目名称:Scene-Editor-for-mobile,代码行数:38,代码来源:NumberCaptcha.php

示例4: guvenlik_resmi

 function guvenlik_resmi()
 {
     $sifre = substr(md5(rand(0, 999999999999)), -5);
     if ($sifre) {
         $this->session->set_userdata('koruma', $sifre);
         $yukseklik = 62;
         $genislik = 200;
         $resim = ImageCreate($genislik, $yukseklik);
         $siyah = ImageColorAllocate($resim, 0, 0, 0);
         $kirmizi = ImageColorAllocate($resim, 182, 16, 99);
         $beyaz = ImageColorAllocate($resim, 255, 255, 255);
         ImageFill($resim, 0, 0, $beyaz);
         $font = 'css/comic.ttf';
         $font_boyut = 24;
         $sM = 30;
         $uM = 45;
         //kullanımı
         //resim adı, font boyutu, yazının açısı, yazının soldan margini, üstten margin, renk, font adı, şifrenin hangi digitinin yazılacağı bellirtiliyor
         imagettftext($resim, $font_boyut, rand(-45, 45), $sMa = $sM, $uM, rand(0, 255), $font, $sifre[0]);
         imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[1]);
         imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[2]);
         imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[3]);
         imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[4]);
         //ImageRectangle($resim, 0, 0, $genislik-1, $yukseklik-1, $kirmizi);
         imageline($resim, 0, $yukseklik / 2, $genislik, $yukseklik / 2, $kirmizi);
         imageline($resim, $genislik / 2, 0, $genislik / 2, $yukseklik, $kirmizi);
         header("Content-Type: image/png");
         ImagePng($resim);
         ImageDestroy($resim);
     }
     exit;
 }
开发者ID:alyayazilim,项目名称:Servis-Takip,代码行数:32,代码来源:Sistem_yonetimi.php

示例5: create

 function create($varDesc, $varValues)
 {
     Header("Content-type: image/png");
     $image = ImageCreate($this->imageWidth, $this->imageHeight);
     $bgcolor = ImageColorAllocate($image, $this->bgR, $this->bgG, $this->bgB);
     $white = ImageColorAllocate($image, 255, 255, 255);
     $black = ImageColorAllocate($image, 0, 0, 0);
     ImageFill($image, 0, 0, $bgcolor);
     $num = 0;
     foreach ($varDesc as $v) {
         $r = rand(0, 255);
         $g = rand(0, 255);
         $b = rand(0, 255);
         $sliceColors[$num] = ImageColorAllocate($image, $r, $g, $b);
         $num++;
     }
     // now $num has the number of elements
     // draw the box
     ImageLine($image, 0, 0, $this->imageWidth - 1, 0, $black);
     ImageLine($image, $this->imageWidth - 1, 0, $this->imageWidth - 1, $this->imageHeight - 1, $black);
     ImageLine($image, $this->imageWidth - 1, $this->imageHeight - 1, 0, $this->imageHeight - 1, $black);
     ImageLine($image, 0, $this->imageHeight - 1, 0, 0, $black);
     $total = 0;
     for ($x = 0; $x < $num; $x++) {
         $total += $varValues[$x];
     }
     // convert each slice into corresponding percentage of 360-degree circle
     for ($x = 0; $x < $num; $x++) {
         $angles[$x] = $varValues[$x] / $total * 360;
     }
     for ($x = 0; $x < $num; $x++) {
         // calculate and draw arc corresponding to each slice
         ImageArc($image, $this->imageWidth / 4, $this->imageHeight / 2, $this->imageWidth / 3, $this->imageHeight / 3, $angle, $angle + $angles[$x], $sliceColors[$x]);
         $angle = $angle + $angles[$x];
         $x1 = round($this->imageWidth / 4 + $this->imageWidth / 3 * cos($angle * pi() / 180) / 2);
         $y1 = round($this->imageHeight / 2 + $this->imageHeight / 3 * sin($angle * pi() / 180) / 2);
         // demarcate slice with another line
         ImageLine($image, $this->imageWidth / 4, $this->imageHeight / 2, $x1, $y1, $sliceColors[$x]);
     }
     // fill in the arcs
     $angle = 0;
     for ($x = 0; $x < $num; $x++) {
         $x1 = round($this->imageWidth / 4 + $this->imageWidth / 3 * cos(($angle + $angles[$x] / 2) * pi() / 180) / 4);
         $y1 = round($this->imageHeight / 2 + $this->imageHeight / 3 * sin(($angle + $angles[$x] / 2) * pi() / 180) / 4);
         ImageFill($image, $x1, $y1, $sliceColors[$x]);
         $angle = $angle + $angles[$x];
     }
     // put the desc strings
     ImageString($image, 5, $this->imageWidth / 2, 60, "Legend", $black);
     for ($x = 0; $x < $num; $x++) {
         $fl = sprintf("%.2f", $varValues[$x] * 100 / $total);
         $str = $varDesc[$x] . " (" . $fl . "%)";
         ImageString($image, 3, $this->imageWidth / 2, ($x + 5) * 20, $str, $sliceColors[$x]);
     }
     // put the title
     ImageString($image, 5, 20, 20, $this->title, $black);
     ImagePng($image);
     ImageDestroy($image);
 }
开发者ID:loopzy,项目名称:my,代码行数:59,代码来源:piemaker.php

示例6: ResizeImage

function ResizeImage($Filename, $Thumbnail, $Size)
{
    $Path = pathinfo($Filename);
    $Extension = $Path['extension'];
    $ImageData = @GetImageSize($Filename);
    $Width = $ImageData[0];
    $Height = $ImageData[1];
    if ($Width >= $Height and $Width > $Size) {
        $NewWidth = $Size;
        $NewHeight = $Size / $Width * $Height;
    } elseif ($Height >= $Width and $Height > $Size) {
        $NewWidth = $Size / $Height * $Width;
        $NewHeight = $Size;
    } else {
        $NewWidth = $Width;
        $NewHeight = $Height;
    }
    $NewImage = @ImageCreateTrueColor($NewWidth, $NewHeight);
    if (preg_match('/^gif$/i', $Extension)) {
        $Image = @ImageCreateFromGif($Filename);
    } elseif (preg_match('/^png$/i', $Extension)) {
        $Image = @ImageCreateFromPng($Filename);
    } else {
        $Image = @ImageCreateFromJpeg($Filename);
    }
    if ($ImageData[2] == IMAGETYPE_GIF or $ImageData[2] == IMAGETYPE_PNG) {
        $TransIndex = imagecolortransparent($Image);
        // If we have a specific transparent color
        if ($TransIndex >= 0) {
            // Get the original image's transparent color's RGB values
            $TransColor = imagecolorsforindex($Image, $TransIndex);
            // Allocate the same color in the new image resource
            $TransIndex = imagecolorallocate($NewImage, $TransColor['red'], $TransColor['green'], $TransColor['blue']);
            // Completely fill the background of the new image with allocated color.
            imagefill($NewImage, 0, 0, $TransIndex);
            // Set the background color for new image to transparent
            imagecolortransparent($NewImage, $TransIndex);
        } elseif ($ImageData[2] == IMAGETYPE_PNG) {
            // Turn off transparency blending (temporarily)
            imagealphablending($NewImage, false);
            // Create a new transparent color for image
            $color = imagecolorallocatealpha($NewImage, 0, 0, 0, 127);
            // Completely fill the background of the new image with allocated color.
            imagefill($NewImage, 0, 0, $color);
            // Restore transparency blending
            imagesavealpha($NewImage, true);
        }
    }
    @ImageCopyResampled($NewImage, $Image, 0, 0, 0, 0, $NewWidth, $NewHeight, $Width, $Height);
    if (preg_match('/^gif$/i', $Extension)) {
        @ImageGif($NewImage, $Thumbnail);
    } elseif (preg_match('/^png$/i', $Extension)) {
        @ImagePng($NewImage, $Thumbnail);
    } else {
        @ImageJpeg($NewImage, $Thumbnail);
    }
    @chmod($Thumbnail, 0644);
}
开发者ID:kelsh,项目名称:classic,代码行数:58,代码来源:notgallery.php

示例7: avg_percent_fit_iskill

 function avg_percent_fit_iskill($db_object, $common, $image, $user_id)
 {
     $user_table = $common->prefix_table("user_table");
     $model_factors_1 = $common->prefix_table("model_factors_1");
     $model_percent_fit = $common->prefix_table("models_percent_fit");
     $family_position = $common->prefix_table("family_position");
     $career_goals = $common->prefix_table("career_goals");
     $sql = "select position from {$user_table} where user_id='{$user_id}'";
     $sql_res = $db_object->get_a_line($sql);
     $pos_id = $sql_res[position];
     $user_pos = $common->get_chain_below($pos_id, $db_object, $twodarr);
     $count = 0;
     if (count($user_pos) == 0) {
         $heads = array(array("No employee", 3, "c"), array("under this admin", 3, "c"));
         $image = ImageCreate(150, 150);
         $white = ImageColorAllocate($image, 255, 255, 255);
         $black = ImageColorAllocate($image, 0, 0, 0);
         ImageString($image, $heads[0][1], 10, 0, $heads[0][0], $black);
         ImageString($image, $heads[1][1], 10, 15, $heads[1][0], $black);
         //ImageString($image,3,50,50,'heading',16);
         ImagePng($image);
     }
     for ($i = 0; $i < count($user_pos); $i++) {
         $pos = $user_pos[$i];
         $sql = "select user_id from {$user_table} where position='{$pos}'";
         $user_res = $db_object->get_a_line($sql);
         $user = $user_res[user_id];
         $sql = "select onelevel_up from {$career_goals} where user_id='{$user}'";
         $fly_res = $db_object->get_single_column($sql);
         if (count($fly_res) > 0) {
             $family_ids = @implode(",", $fly_res);
             $fly = "(" . $family_ids . ")";
             $sql = "select model_id from {$model_factors_1} where family in {$fly}";
             $model_arr = $db_object->get_single_column($sql);
             if (count($model_arr) > 0) {
                 $model_ids = @implode(",", $model_arr);
                 $models = "(" . $model_ids . ")";
                 $sql = "select avg(percent_fit) as percent from {$model_percent_fit} where model_id in {$models} \n\t\t\t\t\t\n\t\t\t\t\tand user_id='{$user}'";
                 $percent_arr = $db_object->get_a_line($sql);
                 $total_percent += $percent_arr[0];
                 $count++;
             }
         }
     }
     if ($count >= 1) {
         $percent = $total_percent / $count;
     } else {
         $percent = 0;
     }
     $total = 100;
     $heads = array(array("One Level Up Fit", 3, "c"));
     $array = array($percent, $total);
     $vals = $image->return_Array($array);
     $image->init(150, 150, $vals);
     $image->draw_heading($heads);
     $image->set_legend_percent();
     $image->display($filename);
 }
开发者ID:nloadholtes,项目名称:people-prodigy,代码行数:58,代码来源:admin_levelup_fit.php

示例8: png

function png($panels, $name)
{
    if (count($panels) > 0) {
        echo "Les images générées vont être enregistrées au format PNG.\n";
    }
    $i = 0;
    while (isset($panels[$i])) {
        ImagePng($panels[$i], $name . $i . ".png");
        $i++;
    }
}
开发者ID:amira-s,项目名称:etna-projects,代码行数:11,代码来源:saveimg.php

示例9: png

 public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4, $saveandprint = FALSE)
 {
     $image = self::image($frame, $pixelPerPoint, $outerFrame, $saveandprint);
     if ($filename === false) {
         Header("Content-type: image/png");
         ImagePng($image);
     } else {
         ImagePng($image, $filename);
     }
     ImageDestroy($image);
 }
开发者ID:codingoneapp,项目名称:codingone,代码行数:11,代码来源:qrimage.php

示例10: FlushObject

 public function FlushObject()
 {
     if ($this->mStyle & BCS_BORDER) {
         $this->DrawBorder();
     }
     if ($this->mStyle & BCS_IMAGE_PNG) {
         ImagePng($this->mImg);
     } else {
         if ($this->mStyle & BCS_IMAGE_JPEG) {
             ImageJpeg($this->mImg);
         }
     }
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:13,代码来源:cmb128bobject.php

示例11: go

 /**
  * Override the parent's go method because there is no view manager here--we're outputting the image directly.
  */
 public function go()
 {
     $config = Config::getInstance();
     $this->setContentType('image/png');
     $random_num = rand(1000, 99999);
     $_SESSION['ckey'] = md5($random_num);
     $img = rand(1, 4);
     $img_handle = imageCreateFromPNG($config->getValue('source_root_path') . "webapp/assets/img/captcha/bg" . $img . ".PNG");
     $color = ImageColorAllocate($img_handle, 0, 0, 0);
     ImageString($img_handle, 5, 20, 13, $random_num, $color);
     ImagePng($img_handle);
     ImageDestroy($img_handle);
 }
开发者ID:rayyan,项目名称:ThinkUp,代码行数:16,代码来源:class.CaptchaImageController.php

示例12: avg_percent_fit_iskill

 function avg_percent_fit_iskill($db_object, $common, $image, $user_id)
 {
     $user_table = $common->prefix_table("user_table");
     $model_factors_1 = $common->prefix_table("model_factors_1");
     $model_percent_fit = $common->prefix_table("models_percent_fit");
     $family_position = $common->prefix_table("family_position");
     $users = $common->return_direct_reports($db_object, $user_id);
     for ($i = 0; $i < count($users); $i++) {
         $user = $users[$i];
         $sql = "select position from {$user_table} where user_id='{$user}'";
         $pos_res = $db_object->get_a_line($sql);
         $pos = $pos_res[position];
         $sql = "select family_id from {$family_position} where position_id='{$pos}'";
         $fly_res = $db_object->get_single_column($sql);
         if (count($fly_res) > 0) {
             $family_ids = @implode(",", $fly_res);
             $fly = "(" . $family_ids . ")";
             $sql = "select model_id from {$model_factors_1} where family in {$fly}";
             $model_arr = $db_object->get_single_column($sql);
             if (count($model_arr) > 0) {
                 $model_ids = @implode(",", $model_arr);
                 $models = "(" . $model_ids . ")";
                 $sql = "select avg(percent_fit) as percent from {$model_percent_fit} where model_id in {$models} \n\t\t\t\t\t\n\t\t\t\t\tand user_id='{$user}' and skill_type='i'";
                 $percent_arr = $db_object->get_a_line($sql);
                 $total_percent += $percent_arr[0];
             }
         }
     }
     if (count($users) >= 1) {
         $percent = $total_percent / count($users);
         $total = 100;
         $heads = array(array("IP Percentage Fit", 3, "c"));
         $array = array($percent, $total);
         $vals = $image->return_Array($array);
         $image->init(150, 150, $vals);
         $image->draw_heading($heads);
         $image->set_legend_percent();
         $image->display($filename);
     } else {
         $heads = array(array("No employee", 3, "c"), array("under this boss", 3, "c"));
         $image = ImageCreate(150, 150);
         $white = ImageColorAllocate($image, 255, 255, 255);
         $black = ImageColorAllocate($image, 0, 0, 0);
         ImageString($image, $heads[0][1], 10, 0, $heads[0][0], $black);
         ImageString($image, $heads[1][1], 10, 15, $heads[1][0], $black);
         //ImageString($image,3,50,50,'heading',16);
         ImagePng($image);
     }
 }
开发者ID:nloadholtes,项目名称:people-prodigy,代码行数:49,代码来源:reports_avg_percent_fit_iskill.php

示例13: create_code

 public function create_code($value, $img_name)
 {
     $value = $_GET['url'];
     //二维码内容
     $QR = $this->path . $img_name . '.png';
     if (!file_exists($QR)) {
         //生成二维码图片
         QRcode::png($value, $QR, $this->errorCorrectionLevel, $this->matrixPointSize, 2);
     }
     if ($this->start) {
         $QR = $this->logo_code($QR);
     }
     Header("Content-type: image/png");
     ImagePng($QR);
 }
开发者ID:dlpc,项目名称:ecshop,代码行数:15,代码来源:codeImg.php

示例14: png

 /**
  * @param $frame
  * @param bool $filename
  * @param int $pixelPerPoint
  * @param int $outerFrame
  * @param bool $saveAndPrint
  * @param RgbColor $fgColor
  * @param RgbColor $bgColor
  */
 public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4, $saveAndPrint = false, RgbColor $fgColor = null, RgbColor $bgColor = null)
 {
     $image = static::image($frame, $pixelPerPoint, $outerFrame, $fgColor, $bgColor);
     if ($filename === false) {
         Header("Content-type: image/png");
         ImagePng($image);
     } else {
         ImagePng($image, $filename);
         if ($saveAndPrint === true) {
             header("Content-type: image/png");
             ImagePng($image);
         }
     }
     ImageDestroy($image);
 }
开发者ID:chenyongze,项目名称:yii2-qrcode-helper,代码行数:24,代码来源:Image.php

示例15: kleeja_cpatcha_image

function kleeja_cpatcha_image()
{
    //Let's generate a totally random string using md5
    $md5_hash = md5(rand(0, 999));
    //I think the bad things in captcha is two things, O and 0 , so let's remove zero.
    $security_code = str_replace('0', '', $md5_hash);
    //We don't need a 32 character long string so we trim it down to 5
    $security_code = substr($security_code, 15, 5);
    //Set the session to store the security code
    $_SESSION["klj_sec_code"] = $security_code;
    //Set the image width and height
    $width = 150;
    $height = 25;
    //Create the image resource
    $image = ImageCreate($width, $height);
    //We are making three colors, white, black and gray
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, rand(0, 100), 0, rand(0, 50));
    $grey = ImageColorAllocate($image, 204, 204, 204);
    //Make the background black
    ImageFill($image, 0, 0, $black);
    //options
    $x = 10;
    $y = 14;
    $angle = rand(-7, -10);
    //Add randomly generated string in white to the image
    if (function_exists('imagettftext')) {
        //
        // We figure a bug that happens when you add font name without './' before it ..
        // he search in the Linux fonts cache , but when you add './' he will know it's our font.
        //
        imagettftext($image, 16, $angle, rand(50, $x), $y + rand(1, 3), $white, './arial.ttf', $security_code);
    } else {
        imagestring($image, imageloadfont('arial.gdf'), $x + rand(10, 15), $y - rand(10, 15), $security_code, $white);
    }
    //kleeja !
    imagestring($image, 1, $width - 35, $height - 10, 'Kleeja', ImageColorAllocate($image, 200, 200, 200));
    //Throw in some lines to make it a little bit harder for any bots to break
    ImageRectangle($image, 0, 0, $width - 1, $height - 1, $grey);
    imageline($image, 0, $height / 2, $width, $height / 2, $grey);
    imageline($image, $width / 2, 0, $width / 2, $height, $grey);
    //Tell the browser what kind of file is come in
    header("Content-Type: image/png");
    //Output the newly created image in jpeg format
    ImagePng($image);
    //Free up resources
    ImageDestroy($image);
}
开发者ID:kmkDesign,项目名称:phpquran,代码行数:48,代码来源:captcha.php


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