通过二维码图片识别二维码内容方法

 示例代码功能见-识别二维码工具 反解析二维码工具 识别条码工具 反解析条码工具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;
}

转载于:https://www.cnblogs.com/mengzhilva/p/10670222.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值