php識別二維碼和條形碼
阿新 • • 發佈:2018-12-05
使用php-zxing,github地址:https://github.com/dsiddharth2/php-zxing
在使用之前先確保已安裝java環境
另外參考連結:
https://blog.csdn.net/mrwangweijin/article/details/79145677
https://zxing.org/w/decode.jspx
經過本人測試,識別率不是很高,需要離得近才容易識別,而且不能反光
原生代碼大概如下:
use PHPZxing\PHPZxingDecoder;
public function test() { $config = array( 'try_harder' => true, ); $decoder = new PHPZxingDecoder($config); $decoder->setJavaPath('java'); $decodedData = $decoder->decode(ROOT_PATH . 'public/upload/extend/qrcode/58e35c6b-f34e-41e2-9fe1-7595ec927f48.jpg'); echo $decodedData->getImageValue(); }