Home > Article > Backend Development > How to implement QR code recognition in PHP-example sharing
There will be some applications in the display that need to parse and identify the QR code. So how to identify QR codes on the PHP backend? This article will share an example of QR code recognition with PHP. I hope it will be helpful to everyone.
Step One
mageMagick is a free software for creating, editing, and compositing images. It can read, convert, and write images in multiple formats. Picture cutting, color replacement, application of various effects, picture rotation, combination, text, straight lines, polygons, ellipses, curves, extension and rotation attached to pictures. ImageMagick is free software: all source code is open and can be used, copied, modified, and distributed freely. It complies with the GPL license agreement and can run on most operating systems. Most of the functions of ImageMagick come from command line tools.
Convert images from one format to another, including directly to icons.
Resize, rotate, sharpen, reduce color, and picture special effects
A montage of image thumbnails
Suitable for web Pictures with transparent background
Make a group of pictures into gif animation, directly convert
Make several pictures into a combined picture, montage
Write or write on a picture Draw graphics, with text shading and border rendering.
Add borders or frames to pictures
Get some characteristic information of pictures
10, including almost all the regular plug-in functions that gimp can do. It even includes rendering functions for various curve parameters. It's just that the way the command is written is complicated enough.
ImageMagick can be compiled on almost any non-proprietary operating system, whether it is 32-bit or 64-bit CPU, including LINUX, Windows '95/'98/ME/NT 4.0/2000/XP, Macintosh (MacOS 9 /10), VMS and OS/2.
Step 2
ZBar is a commonly used QR code recognition software
Step Three
Install php-zbarcode(https://github.com/mkoppanen/php-zbarcode)
Step Four
Add: extension=zbarcode.so to the php.ini configuration file
Step 5
Identification
<?php //新建一个图像对象 $image = new ZBarCodeImage("./test.png"); // 创建一个二维码识别器 $scanner = new ZBarCodeScanner(); //识别图像 $barcode = $scanner->scan($image); //循环输出二维码信息 if (!empty($barcode)) { foreach ($barcode as $code) { printf("Found type %s barcode with data %s\n", $code['type'], $code['data']); } } ?>
The above is the detailed content of How to implement QR code recognition in PHP-example sharing. For more information, please follow other related articles on the PHP Chinese website!