怎么把照片制作成二维码中间的logo~中间还能看到照片的那种

页面导航:
→ 正文内容 自己定义图片 二维码
php制作中间带自己定义图片二维码的方法
本文为大家介绍下如何使用php制作中间带自己定义图片的二维码,需要的朋友可以参考下
1,首先你必须生成二维码具体代码如下:
代码如下: 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./chart"; $data_Array = array(); foreach($post_data as $key =& $value) { $data_Array[] = $key.'='.$ } $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 $ } function outimgase(){ echo $this-&qrcode(); } } header("Content-type:image/png"); $t = new QRCode(300,300,"tianxin");
2,然后通过一个php文件将二维码和你的目的图片画在一起代码如下: &?php
代码如下: $surl = $_POST["url"]; function GrabImage($url,$filename="") { if($url==""): if($filename=="") { $ext=strrchr($url,"."); if($ext!=".gif" && $ext!=".jpg"): $filename=date("dMYHis").$ } ob_start(); readfile($url); $img = ob_get_contents(); ob_end_clean(); $size = strlen($img); $fp2=@fopen($filename, "a"); fwrite($fp2,$img); fclose($fp2); return $ } $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 $ } else {
} } 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 = strtolower($type); $interlace = $interlace ? 1 : 0; unset($info); $scale = min($maxWidth / $srcWidth, $maxHeight / $srcHeight); // 计算缩放比例 if ($scale &= 1) { // 超过原图大小不再缩略 $width = $srcW $height = $srcH } else { // 缩略图尺寸 $width = (int) ($srcWidth * $scale); $height = (int) ($srcHeight * $scale); } // 载入原图 $createFun = 'ImageCreateFrom' . ($type == 'jpg' ? 'jpeg' : $type); $srcImg = $createFun($image); //创建缩略图 if ($type != 'gif' && function_exists('imagecreatetruecolor')) $thumbImg = imagecreatetruecolor($width, $height); else $thumbImg = imagecreate($width, $height); // 复制图片 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);//设定保存完整的 alpha 通道信息 $background_color = imagecolorallocate($thumbImg, 0, 255, 0); // 指派一个绿色 imagecolortransparent($thumbImg, $background_color); // 设置为透明色,若注释掉该行则输出绿色的图 } // 对jpeg图形设置隔行扫描 if ('jpg' == $type || 'jpeg' == $type) imageinterlace($thumbImg, $interlace); // 生成图片 $imageFun = 'image' . ($type == 'jpg' ? 'jpeg' : $type); $imageFun($thumbImg, $thumbname); imagedestroy($thumbImg); imagedestroy($srcImg); return $ }
} function water($source, $thumb, $savename="", $alpha=100){ //检查文件是否存在 if (!file_exists($source) || !file_exists($thumb))
//图片信息 $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'])
//建立图像 $sCreateFun = "imagecreatefrom" . $sInfo['type']; $sImage = $sCreateFun($source); $wCreateFun = "imagecreatefrom" . $wInfo['type']; $wImage = $wCreateFun($water); //设定图像的混色模式 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 = $ @unlink($source); } //保存图像 $ImageFun($sImage, $savename); imagedestroy($sImage); } water($source,$water);
在上面的代码中用3个函数 GrabImage()函数是将生成二维码的文件转化成图片 接下来的函数就是处理图片的缩放 将目的图片添加到二位上。 3,在来一个入口文件index.html 代码如下:
代码如下: &html& &head& &title& 中间可以自己定义图片的二维码生成器 &/title& &/head& &body style="margin:0 padding:0 font-family:宋体; font-size:12"& &form action="&span style="font-size:18"&&strong&&span style="color:#FF0000;"&注意提交的URL&/span&&/strong&&/span&" method="post"& &div style="width:500 height:200 background-color:#CCCCCC; margin: border-width:1 border-color:#000000;" align="center"& &h1 style="margin:0 padding:20 font-family:宋体; font-size:12"&中间可以自己定义图片的二维码生成器&/h1& &table width="500" border="0"& &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="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&
您可能感兴趣的文章:
上一篇:下一篇:
最 近 更 新
热 点 排 行
12345678910请问大家,有的人做出来的二维码中间有一个字或者一副图片,这是怎么弄出来的哦_百度知道
请问大家,有的人做出来的二维码中间有一个字或者一副图片,这是怎么弄出来的哦
我有更好的答案
您好,很高兴可以回答你的问题,这种二维码被称作是个性二维码,只是中间需要上传一张图片就可以,一般有后台操作的可以直接实现图片的上传,但是网上也有免费的个性二维码生成器,你可以在网上找找看。
二维码分为很多种类,一般普通的二维码(中间什么都没有的)是QR码,别的类型的可能可以实现这种功能,但是你可以把图片或者LOGO放在二维码中央就可以了,只要不遮挡二维码三个角的方框或者整个面积的50%就可以扫出来
其他类似问题
为您推荐:
二维码的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁我想把手机里的所有照片做成二维码形式 只要扫描了二维码就可以看见用照片制成二维码的照片 应该怎么_百度知道
我想把手机里的所有照片做成二维码形式 只要扫描了二维码就可以看见用照片制成二维码的照片 应该怎么
我想把手机里的所有照片做成二维码形式 只要扫描了二维码就可以看见用照片制成二维码的照片
应该怎么做?
最后一句表达的不是很明白,扫描之后看到的是原来的照片么?还是什么都没有?、
就是我制成二维码的图片
比如我拿1 3 5 7 9这几个数字制成二维码
然后扫出来的二维码 就是1 3 5 7 9
这个比较麻烦,打字说的不是很清楚。你有那么多的图片都做成二维码,累死你了。
比如我有一百张图片
我制成一张二维码
可以说是做个归类
二维码是有特殊结构的,并不是你把中间的图片换掉就成了另一张图片了。通俗点说就是,你找到一张二维码,然后放大编辑它,把中间的图片换成你的,扫描之后也不是你的图片。一般会不识别的
其他类似问题
为您推荐:
二维码的相关知识
其他2条回答
只能把图片上传到网上,然后把图片网址做成二给你说个事码
如果传到快盘里可以达到写完的要求吗?
tynutj bput mnijnhbvrynmbv
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁}

我要回帖

更多关于 扫描二维码打印照片 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信