通過二維碼圖片識別二維碼內容方法


 示例代碼功能見-識別二維碼工具 反解析二維碼工具 識別條碼工具 反解析條碼工具http://sberwm.gsjlw.com/

可以通過讀取圖片中的信息,來逆向識別二維碼的內容,

主要使用了ZBarCodeImage這個類的功能。

而這個類需要在服務器上安裝php-zbarcode 具體安裝方法見https://www.cnblogs.com/mengzhilva/p/10670228.html

$url = $_GET['url'];
$urlimg = $url;
$img = togetc($urlimg);

$name = substr($url,1+strrpos($url,'/'));
//var_dump($name);exit;
$img = file_put_contents('Public/Uploads/'.$name,$img);
//var_dump($img);exit;
//新建一個圖像對象
//$image = new ZBarCodeImage('4324.jpg');
$image = new ZBarCodeImage('Public/Uploads/'.$name);

// 創建一個二維碼識別器
$scanner = new ZBarCodeScanner();

//識別圖像
$barcode = $scanner->scan($image);
echo json_encode($barcode);exit;
//循環輸出二維碼信息
if (!empty($barcode)) {
foreach ($barcode as $code) {
printf("Found type %s barcode with data %s\n", $code['type'], $code['data']);
}
}

function togetc($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$a = curl_exec($ch);
return $a;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM