PHP生成带LOGO的二维码图像
现在二维码是我们一些软件站或下载站常用的一种东西了,特别是微信都会使用二维码来加好友,下面我来介绍利用php生成二维码多种方法.
方法一,这种生成就是一个二维码中间不带图片的,直接调用google的一个功能就实现了,代码如下:
<?php $urlToEncode="http://gz.altmi.com"; generateQRfromGoogle($urlToEncode); function generateQRfromGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0') //开源代码phprm.com { $url = urlencode($url); echo '<img src="/static/imghw/default1.png" data-src="http://chart.apis.google.com/chart?chs='.$widhtHeight.'x'.$widhtHeight.'&cht=qr&chld='.$EC_level.'|'.$margin.'&chl='.$chl.'" class="lazy" alt="QR code" widhtHeight="'.$size.'" widhtHeight="'.$size.'"/>'; } ?>
生成像微信一样中间有logo二维码,代码如下:
<?php // QR Code + Logo Generator QR图片中间加logo $data = isset($_GET['data']) ? $_GET['data'] : 'http://www.phprm.com'; $size = isset($_GET['size']) ? $_GET['size'] : '130x130'; $logo = isset($_GET['logo']) ? $_GET['logo'] : './20130128160755.jpg';//中间那logo图 $chl = urlencode($logo); $png = "http://chart.googleapis.com/chart?chs=$size&cht=qr&chl=$chl&chld=L|1&choe=UTF-8"; $QR = imagecreatefrompng($png);//外面那QR图 if ($logo !== FALSE) { $logo = imagecreatefromstring(file_get_contents($logo)); $QR_width = imagesx($QR); $QR_height = imagesy($QR); $logo_width = imagesx($logo); $logo_height = imagesy($logo); $logo_qr_width = $QR_width/5; $scale = $logo_width/$logo_qr_width; $logo_qr_height = $logo_height/$scale; $from_width = ($QR_width-$logo_qr_width)/2; imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height); } header('Content-type: image/png'); imagepng($QR); imagedestroy($QR); ?>
最后分享一些常用的二维码生成插件下载地址
1,地址:http://phpqrcode.sourceforge.net/
下载:http://sourceforge.net/projects/phpqrcode/
2.libqrencode
地址:http://fukuchi.org/works/qrencode/index.en.html
php支持请参考:http://hirokawa.netflowers.jp/entry/4900/
3.QRcode Perl CGI & PHP scripts
地址:http://www.swetake.com/qr/qr_cgi.html
本文地址:
转载随意,但请附上文章地址:-)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

