Php calls the google interface to generate a QR code example
Source: Internet
Author: User
There may be many ways for php to generate a QR code. This article mainly calls the google interface to generate a QR code. For more information, see
The code is as follows:
$ Data = isset ($ _ GET ['t'])? $ _ GET ['t']: 'http: // www.XXX.com ';
$ Size = isset ($ _ GET ['size'])? $ _ GET ['size']: '150x150 ';
$ Logo = isset ($ _ GET ['logo '])? $ _ GET ['logo ']: "./image/logo.jpg ";
$ Chlorophyll = urlencode ($ logo );
$ Png = "http://chart.googleapis.com/chart? Chs = $ size & cht = qr & chlorophyll = $ chlorophyll & chld = L | 1 & choe = UTF-8 ";
$ QR = imagecreatefrompng ($ png); // The QR image outside
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 );
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.