示例代碼功能見-識別二維碼工具 反解析二維碼工具 識別條碼工具 反解析條碼工具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;
}