Personalize your own QR code, personalize your own QR Code _php tutorial

Source: Internet
Author: User
Tags nets

Personalize your QR code and personalize your own QR code


First, what is the QR code

Second, we how to make two-dimensional code

Third, how to make their own personality QR code

1, the first step. Download PHP class library Phpqrcode, (with download address: http://sourceforge.net/projects/phpqrcode/)

The list of use cases given online is:

 
  

2, read the above code

What happened to that piece of code?

Let me open the phpqrcode.php to see, the code is too long, do not post, you download it.

Combined with the above code and phpqrcode.php, take a look at:

 Encodepng ($value, False, $saveandprint =false); try {ob_start (); $tab = $enc->encode ($intext);p rint_r ($tab); $err = OB _get_contents (); Ob_end_clean (); if ($err! = ") Qrtools::log ($outfile, $err);/* Tag */$maxSize = (int) (qr_png_maximum_ SIZE/(Count ($tab) +2* $enc->margin)); Qrimage::p ng ($tab, $outfile, Min (max (1, $enc->size), $maxSize), $enc->margin, $saveandprint);} catch (Exception $e) {qrtools::log ($outfile, $e->getmessage ());} Exit;? >

We can find that PHP class library Phpqrcode first through an algorithm to convert the text we need to an array of $tab, and then through the image operation to draw a picture, which is our QR code.

If you print an array of $tab, you'll find him like this:

Array ([0] = 1111111010101001001111111 [1] = 1000001001111001001000001 [2] = 101110101110000110101110    1 [3] = = 1011101011101110101011101 [4] = 1011101010011010001011101 [5] = 1000001000110111001000001 [6] = = 1111111010101010101111111 [7] = 0000000000101111100000000 [8] = 1111001010110000110011101 [9] = > 1010100010101110100111100 [Ten] = 1011011111111111111000111 [one] = 0010010011100000100001000 [] =&G T 0101111111101001100101100 [] = 0100010111010111010001001 [+] = 0110101010110111010100001 [10] 01110110101100110111101 [+] = 0000101100110100111110000 [+] = 0000000011110101100010101 [+] + 1111 111001010110101011010 [+] = 1000001001101100100010101 [101110] [+] = 1011101001100001111110001 1010010110000000011 [[] = 1011101011000111011001110 [] = 1000001011001010001001000 [11111110] = 11000100100101111)

Well, do you understand ........

Now it's easy, according to the array $tab, drawing can be:

Qrimage::p ng ($tab, $outfile, Min (max (1, $enc->size), $maxSize), $enc->margin, $saveandprint);

3. How to Draw

If we all study the source code, we will find that the most critical is such a method:

private static function image ($frame, $pixelPerPoint = 4, $outerFrame = 4);

Below the source I commented out (the original class library is not annotated)

 

4, their own is the practical.

So .......

(1) Can the "black point" be turned into a colored dot? Into Love? and become a picture of your girlfriend? into words?

(2) Can the middle part of the image add something, a "love" word, or what can express the mind of things?

5. Write your Own method

private static function MyImage ($frame, $pixelPerPoint = 4, $outerFrame = 4, $point, $centerPoint) {/* * Array $point indicates the fill The style of the filled point * array $centerPoint the style that represents the middle part of the picture * $point = Array (' kind ' + = ',//col,img,word ' info ' = '//rgb,filename ') * $cen Terpoint = Array (' kind ' = ' = ',//col,img,word ' info ' = ') * not finished, but the idea is the same */if ($point [' kind '] = = ' col ') {$R 1 = $point [' Info '] [' 0 '] [' R ']; $G 1 = $point [' info '] [' 0 '] [' G ']; $B 1 = $point [' info '] [' 0 '] [' B ']; $R 2 = $point [' info '] [' 1 '] [' R ']; $G 2 = $point [' Info '  [' 1 '] [' G ']; $B 2 = $point [' info '] [' 1 '] [' B ']; $h = count ($frame); $w = strlen ($frame [0]); $imgW = $w + * * * $outerFrame; $imgH = $h + $outerFrame $base _image =imagecreate ($imgW, $imgH); $col [0] = imagecolorallocate ($base _image, $R 1, $G 1, $B 1); $col [1 ] = Imagecolorallocate ($base _image, $R 2, $G 2, $B 2); Imagefill ($base _image, 0, 0, $col [0]); for ($y =0; $y < $h; $y + +) {for ($ x=0; $x < $w; $x + +) {if ($frame [$y] [$x] = = ' 1 ') {Imagesetpixel ($base _image, $x + $outerFrame, $y + $outerFrame, $col [1]);}} X$target_Image =imagecreate ($imgW * $pixelPerPoint, $imgH * $pixelPerPoint); imagecopyresized ($target _image, $base _image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH); Imagedestroy ($base _image); return $target _image;} ElseIf ($point [' kind '] = = ' img ') {function getsquare ($image, $multi) {$imgW = Imagesx ($image); $imgH = Imagesy ($image); $ imgmin = min ($imgH, $imgW); $target _image =imagecreatetruecolor ($imgMin, $imgMin); imagecopyresampled ($target _image, $ Image, 0, 0, 0, 0, $imgMin, $imgMin, $imgW, $imgH);//imagecopyresized ($target _image, $image, 0, 0, 0, 0, $imgW * $multi, $imgH * $multi, $imgW, $imgH) $multi _image =imagecreatetruecolor ($imgMin * $multi, $imgMin * $multi); Imagecopyresampled ( $multi _image, $target _image, 0, 0, 0, 0, $imgMin * $multi, $imgMin * $multi, $imgMin, $imgMin);//imagecopyresized ($target _ Image, $image, 0, 0, 0, 0, $imgW * $multi, $imgH * $multi, $imgW, $imgH); Imagedestroy ($image); return $multi _image;} function Getsamesize ($image, $pixelPerPoint) {$imgW = Imagesx ($image); $imgH = Imagesy ($image), $target _image =imagecreatetruecolor ($pixelPerPoint, $pixelPerPoint); Imagecopyresized ($ Target_image, $image, 0, 0, 0, 0, $pixelPerPoint, $pixelPerPoint, $imgW, $imgH);//imagecopyresized ($target _image, $image , 0, 0, 0, 0, $imgW * $multi, $imgH * $multi, $imgW, $imgH); Imagedestroy ($image); return $target _image;} $h = count ($frame), $w = strlen ($frame [0]), $imgW = $w + * * $outerFrame; $imgH = $h + $ $outerFrame; $base _image =imagecreate ($ imgw* $pixelPerPoint, $imgH * $pixelPerPoint); Imagefill ($base _image, 0, 0, imagecolorallocate ($base _image,255,255,255 ); $pointimg = Imagecreatefromjpeg ($point [' info ']), $newimg = Getsquare ($pointimg, 1); $newimgpoint = Getsamesize ($ Newimg, $pixelPerPoint), for ($y =0; $y < $h; $y + +) {for ($x =0; $x < $w; $x + +) {if ($frame [$y] [$x] = = ' 1 ') { Imagecopyresampled ($base _image, $newimgpoint, $y * $pixelPerPoint, $x * $pixelPerPoint, 0, 0, $pixelPerPoint, $ Pixelperpoint, $pixelPerPoint, $pixelPerPoint);}}} return $base _image;} ElseIf ($point [' kind '] = = ' word ') {}else{$h = count ($frame), $w = strlen ($frame [0]), $imgW = $w + * * * $outerFrame; $imgH = $h + $outerFrame; $base _image =imagecre Ate ($imgW, $imgH); $col [0] = imagecolorallocate ($base _image,255,255,255); $col [1] = Imagecolorallocate ($base _image, 0,0,0) Imagefill ($base _image, 0, 0, $col [0]), for ($y =0; $y < $h; $y + +) {for ($x =0; $x < $w; $x + +) {if ($frame [$y] [$x] = = ' 1 ') {Imagesetpixel ($base _image, $x + $outerFrame, $y + $outerFrame, $col [1]);}}} X$target_image =imagecreate ($imgW * $pixelPerPoint, $imgH * $pixelPerPoint); Imagecopyresized ($ Target_image, $base _image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH); Imagedestroy ($base _im   (age); return $target _image;} }

Personality QR Code how to do?

At present, regardless of the enterprise or personal website, even the media platform has posted its own QR code, one can cater to market demand, and secondly can get the attention. Due to the continuous expansion of the two-dimensional code requirements, there are more and more types of two-dimensional code generators on the market. However, most of the two-dimensional code generator generated by the two-dimensional code is black and white, the shape is relatively single, no feature. If you want to pursue personality, create color QR code, you can see how sesame nets do.

We see the most in the daily life of the two-dimensional code generator generated by the two-dimensional code is nothing more than the right upper, upper left, the left has a regular square matrix of two-dimensional code, with information access (text, business cards, maps, wifi password, URL, sms, video) and other functions, sesame Two-dimensional code generator is not limited to Sesame Two-dimensional code generator can not only through the input text, business cards, URLs, WIFI, maps, pictures, MP3, sesame and other information to generate two-dimensional code, but also in accordance with user preferences to change the shape of color or even personality template generated with a personalized pattern and color of the two-dimensional code.
Two-dimensional code interface generated by Sesame net
How to generate color QR code in sesame net
1. Register as a sesame user
2. Select any type of text, business card, URL, WIFI, map, picture, MP3, sesame.
3, fill in the content to generate two-dimensional code, you can choose the ordinary two-dimensional code and personalized template. If you choose the ordinary two-dimensional code can be based on personal preferences to choose a favorite color, add logo or adjust the shape to generate two-dimensional code; If you choose a personalized template can choose the template you like to generate a personalized fun QR code, the right can display real-time generated QR code preview, and finally to download the generated QR code to local!
Ordinary two-dimensional code
Personalized Templates
Generate color QR code very simple, just try it! Sodium

How to create a fun two-dimensional code?

Now there are many online generator software, but mostly nothing new, recently tried to use sesame nets newly baked two-dimensional code generator, sure enough wood to let me down ah, the generator can be arbitrarily adjusted color and gradient way, but also can adjust the shape, add logo, In particular, you can choose to personalize the template to make the QR code become cute and smart.

http://www.bkjia.com/PHPjc/860061.html www.bkjia.com true http://www.bkjia.com/PHPjc/860061.html techarticle personalized their own two-dimensional code, personalized their own two-dimensional code one, what is two-dimensional code two, how we make two-dimensional code three, how to make their own personality QR Code 1, the first step. Download P ...

  • 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.