$numimage = imagecreate($imagewidth,$imageheight); imagecolorall " /> 久久艹伊人,热久久视久久精品2015,同桌上课把奶露出来给我玩

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

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

實例22 圖片驗證的核心代碼
復(fù)制代碼 代碼如下:
<?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函數(shù),用到的時候大家再網(wǎng)上搜索吧。你要產(chǎn)生隨機(jī)數(shù),那有mt_rand函數(shù);你還要用到session保存這個隨機(jī)數(shù);如果需要轉(zhuǎn)成utf-8,需要iconv函數(shù)。

實例23 縮略圖
復(fù)制代碼 代碼如下:
<?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);設(shè)置寬度
$image->save($newfile);
?>

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

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

主站蜘蛛池模板: 国产 欧美 亚洲 日韩视频 | 99热视频这里只有久久精品 | 5G在线观看免费年龄确认 | 青草久久久 | 伊人综合在线影院 | 我强进了老师身体在线观看 | 久久久无码精品亚洲A片软件 | 色一情一乱一伦一区二区三区 | 全免费a级毛片免费看 | 日韩精品免费一区二区 | 麻豆AV无码蜜臀AV色哟 | 伊人久久艹| 扒开女人下面使劲桶视频 | 久久精品国产亚洲AV忘忧草蜜臀 | 国产成人精品自线拍 | 最近韩国日本免费观看mv免费版 | 国产免费啪嗒啪嗒视频看看 | 久久99国产亚洲高清观着 | 成人手机在线 | 亚洲乱码在线卡一卡二卡新区 | 最新果冻传媒在线观看免费版 | 2021国产精品久久久久精品免费网 | 国产成人免费观看在线视频 | 奇米网一区二区三区在线观看 | 久久99re6热在线播放 | 恋夜直播午夜秀场最新 | 999视频精品全部免费观看 | 伊人精品影院一本到综合 | 国产精品自在拍在线播放 | 交换年轻夫妇HD中文字幕 | 花蝴蝶在线观看免费中文版高清 | 桃花免费高清在线观看 | 羞羞在线观看 | 全黄H全肉细节文短篇 | 亚洲高清国产拍精品影院 | 超碰97视频在线观看 | 国语自产偷成人精品视频 | 日韩一区精品视频一区二区 | 国产亚洲AV无码成人网站 | 一个人在线观看免费高清视频在线观看 | 少妇精品无码一区二区三区 |