欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

教你用php將二維碼和文字結(jié)合到一個背景圖片上!

創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務,包含不限于網(wǎng)站設計制作、網(wǎng)站建設、賀蘭網(wǎng)絡推廣、小程序制作、賀蘭網(wǎng)絡營銷、賀蘭企業(yè)策劃、賀蘭品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務,您的肯定,是我們大的嘉獎;創(chuàng)新互聯(lián)公司為所有大學生創(chuàng)業(yè)者提供賀蘭建站搭建服務,24小時服務熱線:18980820575,官方網(wǎng)址:aaarwkj.com

將二維碼生成到背景圖片上,并且文字生成到背景圖上,可以無限制擴增

1.生成前的圖片

生成后的圖片

class codeImg
{
	private $date,$img,$main,$width,$height,$target,$white;
    	public function constr($source)
    	{
    		$this->date   = '' . date('Ymd') . '/';
	        $this->img    = $this->date . md5($source) . '.jpg';
	        $this->main   = imagecreatefromjpeg($source);
	        $this->width  = imagesx($this->main);
	        $this->height = imagesy($this->main);
	        $this->target = imagecreatetruecolor($this->width, $this->height);
	        $this->white  = imagecolorallocate($this->target, 255, 255, 255);
        		imagefill($this->target, 0, 0, $this->white);
        		imagecopyresampled($this->target, $this->main, 0, 0, 0, 0, $this->width, $this->height, $this->width, $this->height);
    	}
    	/**
	     * 生成二維碼
	     * @param  [type]  $website  [生成二維碼地址]
	     * @param  string  $filename [生成二維路經(jīng)名稱]
	     * @param  string  $level    [這個參數(shù)可傳遞的值分別是L(QR_ECLEVEL_L,7%)、M(QR_ECLEVEL_M,15%)、Q(QR_ECLEVEL_Q,25%)、H(QR_ECLEVEL_H,30%),這個參數(shù)控制二維碼容錯率,不同的參數(shù)表示二維碼可被覆蓋的區(qū)域百分比,也就是被覆蓋的區(qū)域還能識別;]
	     * @param  integer $size     [控制生成圖片的大小,默認為4]
	     * @param  integer $margin [控制生成二維碼的空白區(qū)域大小]
	     * @return [type]            [description]
	     */
	      public function qrencode($website, $filename = false, $level = "L", $size = 4, $margin = 2)
	      {
	      		include "./phpqrcode/qrlib.php";
        			QRcode::png($website, $filename, $level, $size, 2);
	      }
	      /**
	     * 把二維碼圖片生成到背景圖片上及文字
	     * @param  string  $source      背景圖片
	     * @param  string  $text1       文字描述
	     * @param  string  $child1      二維碼圖
	     * @param  integer $textwidth   文字橫向位置
	     * @param  integer $textherght  文字高度
	     * @param  integer $$fontSize   字體大小
	     * @param  integer $cate1,$cate2,$cate3 顏色表
	     * @param  string $font         文字字體
	     * @return [type]               [description]
	     */
	     public function generateFont($source, $text1, $textwidth, $textherght, $fontSize = 18, $cate1 = 255, $cate2 = 250, $cate3 = 250, $font = './font/fangsong_GB2312.ttf')
	     {
	     	$this->constr($source);
        		$fontColor = imagecolorallocate($this->target, $cate1, $cate2, $cate3); //字的RGB顏色
        		$fontBox   = imagettfbbox($fontSize, 0, $font, $text1); //文字水平居中實質(zhì)
        		imagettftext($this->target, $fontSize, 0, $textwidth, $textherght, $fontColor, $font, $text1);
        		$this->createImg();
        		return $this->img;
	     }
	      /**
	     * [generateImg description]
	     * @param  string  $source        背景圖片
	     * @param  string  $codeurl       二維碼圖片
	     * @param  integer  $sourcewidth  二維碼橫向所在位置
	     * @param  integer  $sourceheight 二維碼高度位置
	     * @param  integer $codewidth    二維碼寬度
	     * @param  integer $codeheight   二維碼高度
	     * @return [type]                [description]
	     */
	      public function generateImg($source, $codeurl, $sourcewidth, $sourceheight, $codewidth = 100, $codeheight = 100)
	      {
			$this->constr($source);
        			$child1 = imagecreatefrompng($codeurl);
        			$codewidth = $codewidth > 0 ? $codewidth :imagesx($child1);
        			$codeheight = $codeheight > 0 ? $codeheight : imagesy($child1);
        			imagecopyresampled($this->target, $child1, $sourcewidth, $sourceheight, 0, 0, $codewidth, $codeheight,imagesx($child1),imagesy($child1));
        			imagedestroy($child1);
        			$this->createImg();
        			return $this->img;
		}
		function createImg()
		{
			@mkdir('./' . $this->date);
       			 imagejpeg($this->target, './' . $this->img, 95);
        			imagedestroy($this->main);
        			imagedestroy($this->target);
		}
	}
		$source       = "./img/1000.jpg";
		$codeImg = new codeImg($source);
		$website = "http://www.baidu.com";
		$codeurl = "./temp/code.png";
		$codeImg->qrencode($website, $codeurl);
		#################################
		$text         = "開始了開始了hahhah呵呵";
		$textwidth    = 100;
		$textherght   = 50;
		$generateFont = $codeImg->generateFont($source, $text, $textwidth, $textherght);
		##########################################################
		$sourcewidth  = 200;
		$sourceheight = 150;
		$generateImg  = $codeImg->generateImg($generateFont, $codeurl, $sourcewidth, $sourceheight);
		echo "<img src='" . $generateImg . "'>";
	
	``		

更多相關(guān)知識,請訪問PHP中文網(wǎng)!

本文標題:教你用php將二維碼和文字結(jié)合到一個背景圖片上!
文章位置:http://aaarwkj.com/article42/chsghc.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)網(wǎng)站設計、微信公眾號、靜態(tài)網(wǎng)站、App開發(fā)、網(wǎng)站內(nèi)鏈

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名
我想看日韩一级黄色片| 精品国产一区二区av麻豆| 亚洲欧美一区二区中文字幕| 美女在线视频一区二区三区| 精品亚洲在线一区二区| 成年人在线免费观看国产| 丁香婷婷麻豆激情综合网| 91久久精品人妻一区二区| 亚洲午夜精品一区二区久久| 在线观看精品日本一区二| 日本中文字幕女优观看| 国产精品天干天综合网| 国产91高清免费视频| 久久久国产精品9999综合| 亚洲成人午夜免费在线观看| 久久久久久成人亚洲| 日本精品动漫一区二区三区| 欧美夫妻香蕉视频网站| 全部网站免费在线观看等| 日本午夜视频一区二区| 亚洲区自拍偷拍一区二区| 国产精品美女露脸av毛片| 久久亚洲天堂av丁香| 91观看免费完整版高清| 亚洲日日夜夜噜噜爽爽| 久久国产精品亚洲欧美| 91亚洲国产成人精品性色| 99久久精品国产熟女拳交| 日本美女午夜福利视频| 亚洲一区二区美女av| 熟女俱乐部五十路六十路| 我的农村中年激情熟妇| 国产自产一区二区三区精品| 五月婷久久精品国产亚洲av| 欧美小黄片在线免费看| 内射性感黑丝少妇av| 日本黄色中文字幕在线观看 | 热门精品一区二区三区| 亚洲邻家人妻一区二区| 中文字幕av在线日韩| 久久综合色爱综合欧美|