PHP Two-dimensional Code generation support logo (Phpqrcode)

Source: Internet
Author: User

Complete: Http://pan.baidu.com/s/1mgMoxfE

Revised according to Phpqrcode official original

The main increase was two files

api.php function.php

Api.php can generate two-dimensional code in the form of a get parameter.

Function.php is a simple encapsulated function for easy invocation

<?phpheader ("Content-type: text/html; charset=utf-8"), $data  =getdata (' data '), if (Empty ($data) ) {    $str = "parameter description <br />   data: Data to Transcode <br />    level: Default l  Error correction level: L, M, Q, h<br />   size: Default 4  point size: 1 to 10, for mobile 4 Yes   <br />   margin: Default 1  margin  1 to 10 <br />   logo: The default is empty   intermediate logo  file names need to be placed in the logo/directory  <br />    filename: Default is empty   generated file name   Post-build into the temp/directory  <br />    ";echo  $str;exit;     &NBSP;&NBSP;&NBSP,} $level  =getdata (' Level ', ' L ');//  error correction levels: L, M, Q, h     $size  = GetData (' Size ', ' 4 ');; The size of the/ 4;//  point: 1 to 10, for the mobile phone 4 can be//  the following comments on the QR code to save the image to the local code, if you want to save the picture, replace the second parameter with $filename false$path =   ' temp/'; $margin  =getdata (' Margin ', ' 1 ');//Margin $logo = getdata (' logo '); /logo$filename=getdata ('FileName ');//  generated file name if (!empty ($filename)) {$filename  =  $path. $filename. ' _ '. $size. ' PNG ';} else{$filename =false;} if (!empty ($logo)  && empty ($filename)) {$filename  =  $path. $logo. ' _ '. $size. ' PNG ';} $QR =false;if (!empty ($filename)) {$QR = $path. basename ($filename);} include  "qrlib.php"; $QRcode  = new qrcode (); $QRcode->png ($data, $QR, $level, $size, $margin) if ($logo) {    if (Strpos ($logo, ' http://') ===false) $logo = ' logo/'. $logo;      $QR  = imagecreatefromstring (file_get_contents ($QR));     $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/jpg");     imagepng ($QR); Exit;} if (!empty ($filename)) return  $filename; Function getdata ($name, $default = ") {$getdata =$_get;return  empty ($getdata [$name])? $default: $getdata [$name];}? >
function Gen_qrcode ($str, $size = 5) {include "qrlib.php";     $root _dir = ' temp/';    if (!is_dir ($root _dir)) {@mkdir ($root _dir); @chmod ($root _dir, 0777);} $filename = MD5 ($str. "|".    $size); $filesave = $root _dir. $filename.    PNG ';    if (!file_exists ($filesave)) {qrcode::p ng ($str, $filesave, ' Q ', $size, 2);} Return $root _dir. $filename. ". PNG ";}


PHP Two-dimensional Code generation support logo (Phpqrcode)

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.