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
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 );
Imagedestroy ($ QR );
?>
,