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

php制作中間帶自己定義圖片二維碼的方法

1,首先你必須生成二維碼具體代碼如下:
復(fù)制代碼 代碼如下:
class QRCode{
public $w;
public $h;
public $s;
function __construct($w1,$h1,$s1){
$this->w = $w1;
$this->h = $h1;
$this->s = $s1;
$this->outimgase();
}
function qrcode(){
$post_data = array();
$post_data['cht'] = 'qr';
$post_data['chs'] = $this->w."x".$this->h;
$post_data['chl'] = $this->s;
$post_data['choe'] = "UTF-8";
$url = "http://chart.apis.google.com/chart";
$data_Array = array();
foreach($post_data as $key => $value)
{
$data_Array[] = $key.'='.$value;
}
$data = implode("&",$data_Array);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
function outimgase(){
echo $this->qrcode();
}
}
header("Content-type:image/png");
$t = new QRCode(300,300,"tianxin");

2,然后通過一個php文件將二維碼和你的目的圖片畫在一起代碼如下:

<?php
復(fù)制代碼 代碼如下:
$surl = $_POST["url"];
function GrabImage($url,$filename="") {
if($url==""):return false;endif;
if($filename=="") {
$ext=strrchr($url,".");
if($ext!=".gif" && $ext!=".jpg"):return false;endif;
$filename=date("dMYHis").$ext;
}
ob_start();
readfile($url);
$img = ob_get_contents();
ob_end_clean();
$size = strlen($img);
$fp2=@fopen($filename, "a");
fwrite($fp2,$img);
fclose($fp2);
return $filename;
}
$source = GrabImage("http://localhost/QRCode/QRCode.php","Myqrcode.png");
$water =GrabImage($surl,"t.png");
function getImageInfo($img){
$imageInfo = getimagesize($img);
if ($imageInfo !== false) {
$imageType = strtolower(substr(image_type_to_extension($imageInfo[2]), 1));
$imageSize = filesize($img);
$info = array(
"width" => $imageInfo[0],
"height" => $imageInfo[1],
"type" => $imageType,
"size" => $imageSize,
"mime" => $imageInfo['mime']
);
return $info;
} else {
return false;
}
}
function thumb($image, $thumbname, $type='', $maxWidth=200, $maxHeight=50, $interlace=true) {
// 獲取原圖信息
$info = getImageInfo($image);
if ($info !== false) {
$srcWidth = $info['width'];
$srcHeight = $info['height'];
$type = empty($type) ? $info['type'] : $type;
$type = strtolower($type);
$interlace = $interlace ? 1 : 0;
unset($info);
$scale = min($maxWidth / $srcWidth, $maxHeight / $srcHeight); // 計算縮放比例
if ($scale >= 1) {
// 超過原圖大小不再縮略
$width = $srcWidth;
$height = $srcHeight;
} else {
// 縮略圖尺寸
$width = (int) ($srcWidth * $scale);
$height = (int) ($srcHeight * $scale);
}
// 載入原圖
$createFun = 'ImageCreateFrom' . ($type == 'jpg' ? 'jpeg' : $type);
$srcImg = $createFun($image);
//創(chuàng)建縮略圖
if ($type != 'gif' && function_exists('imagecreatetruecolor'))
$thumbImg = imagecreatetruecolor($width, $height);
else
$thumbImg = imagecreate($width, $height);
// 復(fù)制圖片
if (function_exists("ImageCopyResampled"))
imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $width, $height, $srcWidth, $srcHeight);
else
imagecopyresized($thumbImg, $srcImg, 0, 0, 0, 0, $width, $height, $srcWidth, $srcHeight);
if ('gif' == $type || 'png' == $type) {
//imagealphablending($thumbImg, false);//取消默認的混色模式
//imagesavealpha($thumbImg,true);//設(shè)定保存完整的 alpha 通道信息
$background_color = imagecolorallocate($thumbImg, 0, 255, 0); // 指派一個綠色
imagecolortransparent($thumbImg, $background_color); // 設(shè)置為透明色,若注釋掉該行則輸出綠色的圖
}
// 對jpeg圖形設(shè)置隔行掃描
if ('jpg' == $type || 'jpeg' == $type)
imageinterlace($thumbImg, $interlace);

// 生成圖片
$imageFun = 'image' . ($type == 'jpg' ? 'jpeg' : $type);
$imageFun($thumbImg, $thumbname);
imagedestroy($thumbImg);
imagedestroy($srcImg);
return $thumbname;
}
return false;
}
function water($source, $thumb, $savename="", $alpha=100){
//檢查文件是否存在
if (!file_exists($source) || !file_exists($thumb))
return false;
//圖片信息
$sInfo = getImageInfo($source);
$water = thumb($thumb,"wy.jpg","jpg",$sInfo["width"]/4,$sInfo["height"]/4);
$wInfo = getImageInfo($water);
//如果圖片小于水印圖片,不生成圖片
if ($sInfo["width"] < $wInfo["width"] || $sInfo['height'] < $wInfo['height'])
return false;
//建立圖像
$sCreateFun = "imagecreatefrom" . $sInfo['type'];
$sImage = $sCreateFun($source);
$wCreateFun = "imagecreatefrom" . $wInfo['type'];
$wImage = $wCreateFun($water);
//設(shè)定圖像的混色模式
imagealphablending($wImage, true);
//圖像位置,默認為右下角右對齊
// $posY = $sInfo["height"] - $wInfo["height"];
// $posX = $sInfo["width"] - $wInfo["width"];
$posY = ($sInfo["height"] - $wInfo["height"])/2;
$posX = ($sInfo["width"] - $wInfo["width"])/2;
//生成混合圖像
imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo['width'], $wInfo['height'], $alpha);
//輸出圖像
$ImageFun = 'Image' . $sInfo['type'];
//如果沒有給出保存文件名,默認為原圖像名
if (!$savename) {
$savename = $source;
@unlink($source);
}
//保存圖像
$ImageFun($sImage, $savename);
imagedestroy($sImage);
}
water($source,$water);

在上面的代碼中用3個函數(shù) GrabImage()函數(shù)是將生成二維碼的文件轉(zhuǎn)化成圖片 接下來的函數(shù)就是處理圖片的縮放 將目的圖片添加到二位上。

3,在來一個入口文件index.html 代碼如下:
復(fù)制代碼 代碼如下:
<html>
<head>
<title>
中間可以自己定義圖片的二維碼生成器
</title>
</head>
<body style="margin:0px; padding:0px; font-family:宋體; font-size:12px;">
<form action="<span style="font-size:18px;"><strong><span style="color:#FF0000;">注意提交的URL</span></strong></span>" method="post">
<div style="width:500px; height:200px; background-color:#CCCCCC; margin:auto; border-width:1px; border-color:#000000;" align="center">
<h1 style="margin:0px; padding:20px; font-family:宋體; font-size:12px;">中間可以自己定義圖片的二維碼生成器</h1>
<table width="500" border="0">
<tr>
<td width="250" height="40" align="center" valign="middle">二維碼要生的內(nèi)容:</td>
<td width="250" height="40" align="center" valign="middle">
<label>
<input type="text" name="content" value="">
</label>
</td>
</tr>
<tr>
<td width="250" height="40" align="center" valign="middle">希望能添加自己的圖片地址:</td>
<td width="250" height="40" align="center" valign="middle">
<label>
<input type="text" name="url" value="">
</label>
</td>
</tr>
<tr>
<td height="40" colspan="2" align="center" valign="middle">
<label>
<input type="submit" name="Submit" value="生成我想要的二維碼">
</label>
</td>
</tr>
</table>

</div>
</body>
</html>

php技術(shù)php制作中間帶自己定義圖片二維碼的方法,轉(zhuǎn)載需保留來源!

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

主站蜘蛛池模板: 美女医生深夜在家裸睡惨死 | 色婷婷狠狠97成为人免费 | 久久视频这里只精品99热在线 | 亚洲欧美日韩另类精品一区二区三区 | 免费看大黄高清网站视频在线 | 婷婷久久无码欧美人妻 | 被室友C哭调教双性 | 无码AV动漫精品一区二区免费 | 欧美黑人巨大xxxxx | 九九热精品在线 | 色宅男午夜电影网站 | 果冻传媒色AV国产播放 | 美女穿丝袜被狂躁动态图 | 第四色播日韩AV第一页 | 99视频精品国产在线视频 | 国产成人啪精品视频免费网 | 国产精品一久久香蕉国产线看 | 国产综合自拍 偷拍在线 | 免费看到湿的小黄文软件APP | 99久久国产视频 | 古代荡女丫鬟高H辣文纯肉 姑娘视频日本在线播放 | 一本一本之道高清在线观看 | 879影视动漫h免费观看 | 我年轻漂亮的继坶2中字在线播放 | 日本高清免费一本在线观看 | 韩国甜性涩爱 | 91情国产l精品国产亚洲区 | 99福利影院 | 成人a毛片久久免费播放 | 亚洲区视频 | 色爱AV综合区 | 午夜勾魂曲 | 久久免费电影 | 久99视频精品免费观看福利 | 国产精品欧美久久久久天天影视 | 2021精品乱码多人收藏 | 啊灬啊别停灬用力啊在线观看视频 | 麻豆免费观看高清完整视频 | beeg日本老师 | 亚洲手机在线人成视频 | 国产h视频免费观看 |