二維碼三說-——③PHP識別QR二維碼

識別二維碼 需要準備:
ImageMagick 對圖片 -> 讀寫 旋轉 變形
下載:https://imagemagick.org/script/download.php
zbar 從圖片讀取信息
下載:http://zbar.sourceforge.net/download.html
php-zbarcode php組件
下載:https://github.com/mkoppanen/php-zbarcode

配置php-zbarcode
詳情請參照 php拓展的安裝:https://blog.csdn.net/qq_17040587/article/details/83992659


require_once('vendor/autoload.php');

$ZbarDecoder = new RobbieP\ZbarQrdecoder\ZbarDecoder();

# Optionally change the path of the zbarimg executable if you need to (default: /usr/bin)
//$ZbarDecoder->setPath('/usr/local/bin');

# Decode the image
$result = $ZbarDecoder->make('./abc.jpg');

echo $result; // Outputs the decoded text
echo $result->format; // Outputs the barcode's format
echo $result->code; // 200 if it decoded a barcode OR 400 if it couldn't find a barcode
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章