一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

php 生成文字png圖片的代碼

復(fù)制代碼 代碼如下:
<?
/*
php生成文字png圖片,可以使用如下方式調(diào)用函數(shù):
http://www.yourdomian.com/text_png.php3?msg=helloworld+class&rot=15&size=48&font=fonts/ARIAL.TTF
*/
Header("Content-type: image/png");
class textPNG {
var $font = 'fonts/TIMES.TTF'; //默認字體. 相對于腳本存放目錄的相對路徑.
var $msg = "undefined"; // 默認文字.
var $size = 24;
var $rot = 0; // 旋轉(zhuǎn)角度.
var $pad = 0; // 填充.
var $transparent = 1; // 文字透明度.
var $red = 0; // 在黑色背景中...
var $grn = 0;
var $blu = 0;
var $bg_red = 255; // 將文字設(shè)置為白色.
var $bg_grn = 255;
var $bg_blu = 255;
function draw() {
$width = 0;
$height = 0;
$offset_x = 0;
$offset_y = 0;
$bounds = array();
$image = "";
// 確定文字高度.
$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]);
}
// 確定邊框高度.
$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->pad*2)+1,$height+($this->pad*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);
// 畫圖.
ImageTTFText($image, $this->size, $this->rot, $offset_x+$this->pad, $offset_y+$this->pad, $foreground, $this->font, $this->msg);
// 輸出為png格式.
imagePNG($image);
}
}
$text = new textPNG;
if (isset($msg)) $text->msg = $msg; // 需要顯示的文字
if (isset($font)) $text->font = $font; // 字體
if (isset($size)) $text->size = $size; // 文字大小
if (isset($rot)) $text->rot = $rot; // 旋轉(zhuǎn)角度
if (isset($pad)) $text->pad = $pad; // padding
if (isset($red)) $text->red = $red; // 文字顏色
if (isset($grn)) $text->grn = $grn; // ..
if (isset($blu)) $text->blu = $blu; // ..
if (isset($bg_red)) $text->bg_red = $bg_red; // 背景顏色.
if (isset($bg_grn)) $text->bg_grn = $bg_grn; // ..
if (isset($bg_blu)) $text->bg_blu = $bg_blu; // ..
if (isset($tr)) $text->transparent = $tr; // 透明度 (boolean).
$text->draw();
?>

php技術(shù)php 生成文字png圖片的代碼,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 久久精品国产屋 | 综合激情区视频一区视频二区 | 中文字幕色综合久久 | 日韩美女强理论片 | 涩涩涩涩爱 | 2021国产成人午夜精品 | 亚洲视频在线观看一区 | 国产欧美亚洲三区久在线观看 | 干在线视频 | 国内精品视频成人一区二区 | 亚洲国产精品免费视频 | 久久全国免费久久青青小草 | 日日摸夜夜添夜夜添人人爽 | 久久91精品国产91久久户 | 国产午夜视频在线 | 日韩成人免费在线 | 国产成人精品久久一区二区三区 | 国产九九在线 | 午夜欧美性视频在线播放 | 国产高清中文字幕 | 国产精品福利在线播放 | 久久99精品久久久久子伦 | 男啪女色黄无遮挡免费视频 | 久久久免费网站 | 成人午夜免费福利视频 | 欧美ccc| 国产精品自拍一区 | 激情图片小说网 | 久久成人影视 | 日韩avv| 国产精品九九视频 | 中文字幕久久精品 | 综合爱 | 2021国内精品久久久久久影院 | 国产精品一区二区在线播放 | 99精品视频在线观看免费专区 | 久久亚洲精品国产精品婷婷 | 日本高清无卡码一区二区久久 | 成人在线午夜 | 黄视频网页 | 国产91亚洲精品 |