Php calls the google interface to generate a QR code instance
For example, call the google interface to implement the QR code.
- ? Php
- $ 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
- // The following is the main code generated by the QR code.
- 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 );
- // Destroy the QR code image
- Imagedestroy ($ QR );
- ?>
|