$numimage = imagecreate($imagewidth,$imageheight); imagecolorall " /> 久久中文字幕人妻AV熟女,国产精品A久久777777,国产精品悠悠久久人妻精品

天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

《PHP編程最快明白》第七講:php圖片驗證碼與縮略圖

實例22 圖片驗證的核心代碼
復制代碼 代碼如下:
<?php
//header("content-type:image/png");
$num ='1234';
$imagewidth=60;
$imageheight=18;

$numimage = imagecreate($imagewidth,$imageheight);
imagecolorallocate($numimage,240,240,240);
for($i=0;$i<strlen($num);$i++){
$x = mt_rand(1,8)+$imagewidth*$i/4;
$y = mt_rand(1,$imageheight/4);
$color=imagecolorallocate($numimage,mt_rand(0,150),mt_rand(0,150),mt_rand(0,150));
imagestring($numimage,5,$x,$y,$num[$i],$color);
}

for($i=0;$i<200;$i++){
$randcolor=imagecolorallocate($numimage,rand(200,255),rand(200,255),rand(200,255));
imagesetpixel($numimage,rand()%70,rand()%20,$randcolor);
}
imagepng($numimage);
imagedestroy($numimage);
?>

這個是輸出4個驗證碼的例子,對于漢字,需要font文件和imagettftext函數,用到的時候大家再網上搜索吧。你要產生隨機數,那有mt_rand函數;你還要用到session保存這個隨機數;如果需要轉成utf-8,需要iconv函數。

實例23 縮略圖
復制代碼 代碼如下:
<?php
class SimpleImage {
var $image;
var $image_type;
function load($filename) {
$image_info = getimagesize($filename);
$this->image_type = $image_info[2];
if( $this->image_type == IMAGETYPE_JPEG ) {
$this->image = imagecreatefromjpeg($filename);
} elseif( $this->image_type == IMAGETYPE_GIF ) {
$this->image = imagecreatefromgif($filename);
} elseif( $this->image_type == IMAGETYPE_PNG ) {
$this->image = imagecreatefrompng($filename);
}
}
function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) {
if( $image_type == IMAGETYPE_JPEG ) {
imagejpeg($this->image,$filename,$compression);
} elseif( $image_type == IMAGETYPE_GIF ) {
imagegif($this->image,$filename);
} elseif( $image_type == IMAGETYPE_PNG ) {
imagepng($this->image,$filename);
}
if( $permissions != null) {
chmod($filename,$permissions);
}
}
function output($image_type=IMAGETYPE_JPEG) {
if( $image_type == IMAGETYPE_JPEG ) {
imagejpeg($this->image);
} elseif( $image_type == IMAGETYPE_GIF ) {
imagegif($this->image);
} elseif( $image_type == IMAGETYPE_PNG ) {
imagepng($this->image);
}
}
function getWidth() {
return imagesx($this->image);
}
function getHeight() {
return imagesy($this->image);
}
function resizeToHeight($height) {
$ratio = $height / $this->getHeight();
$width = $this->getWidth() * $ratio;
$this->resize($width,$height);
}
function resizeToWidth($width) {
$ratio = $width / $this->getWidth();
$height = $this->getheight() * $ratio;
$this->resize($width,$height);
}
function scale($scale) {
$width = $this->getWidth() * $scale/100;
$height = $this->getheight() * $scale/100;
$this->resize($width,$height);
}
function resize($width,$height) {
$new_image = imagecreatetruecolor($width, $height);
imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
$this->image = $new_image;
}
}

$newfile = UPLOAD_DIR."/icons/".md5($_SESSION['USER']->email).".jpg";//上傳文件保存的目錄
$image = new SimpleImage();
$image->load($_FILES['icons']['tmp_name']);//上傳的臨時文件名
$image->resizeToWidth(80);設置寬度
$image->save($newfile);
?>

php技術《PHP編程最快明白》第七講:php圖片驗證碼與縮略圖,轉載需保留來源!

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

主站蜘蛛池模板: TIMI1TV天美传媒在线观看 | 成人午夜精品无码区久久漫画日本 | 色综合99久久久国产AV | 人与禽物videos另类 | 亚洲视频在线观看网站 | 国产白浆视频在线播放 | 男人的天堂久久精品激情a 男人的天堂黄色片 | 久久久久激情免费观看 | 99亚洲精品自拍AV成人软件 | 亚洲视频精品 | 歪歪爽蜜臀AV久久精品人人槡 | 欧美一区二区VA毛片视频 | 又爽又黄又粗又大免费视频 | xx在线观看 | 国产人妻麻豆蜜桃色精 | 免费看黄软件 | 亲胸揉胸膜下刺激视频网站APP | 精品久久久噜噜噜久久7 | 精品AV无码一二三区视频 | 在线亚洲黄色 | 胸大的姑娘中文字幕视频 | 久久人人爽人人片AV人成 | 亚洲大片在线观看 | 97蜜桃网123.com | 伊人久久久久久久久久 | 疯狂小护士 | 牛牛自拍国产免费视频 | 99久久香蕉国产线看观看 | 国产精品久久久久影院嫩草 | 国产午夜免费视频片夜色 | 免费精品国产人妻国语 | 538久久视频在线 | 成人免费一级毛片在线播放视频 | 日日噜噜噜噜夜夜爽亚洲精品 | 亲胸吻胸添奶头GIF动态图免费 | 曰韩一本道高清无码av | 国产高清视频在线观看不卡v | 全免费A敌肛交毛片免费懂色AV | 亚洲黄色录像片 | 少妇厨房愉情理9伦片视频 少妇被躁爽到高潮无码久久 | 久久精品一区二区影院 |