如何在 PHP 中读取二维码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3899631/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can you read QR Codes in PHP?
提问by Navarr
Is there a plain PHP implementation for decoding QR codes?
是否有用于解码 QR 码的普通 PHP 实现?
I have a faux-smartphone. One of those phones that parades as a smartphone but that I can't download any apps for, and I want to create an email service to where I can take a picture of a QR code, MMS it to this email, and the email returns what the QR code contains.
我有一个假智能手机。其中一款作为智能手机游行但我无法为其下载任何应用程序的手机,我想创建一个电子邮件服务,在那里我可以拍摄二维码的照片,将其彩信发送到该电子邮件,然后电子邮件返回二维码包含什么。
However, the only libraries I've been able to find are in Python (and probably C++), neither of which I can access on my limited hosting environment.
但是,我能找到的唯一库是 Python(可能还有 C++),我无法在有限的托管环境中访问它们。
Is there a way to read QR codes using only PHP?
有没有办法只使用 PHP 读取二维码?
采纳答案by Ashot Khanamiryan
There is only one pure PHP QR code decoder. It's working with GD library, but can use also ImageMagick. This PHP QR code reader is ported from ZXing.
只有一个纯 PHP 二维码解码器。它使用 GD 库,但也可以使用 ImageMagick。这个 PHP 二维码阅读器是从 ZXing 移植的。
回答by smparkes
I'm not aware of any pure php decoder. Decoding images like this is pretty processor intensive and doing it in a purely interpreted language is challenging.
我不知道有任何纯 php 解码器。像这样解码图像是非常占用处理器的,并且用纯解释性语言进行解码是具有挑战性的。
zxing (http://code.google.com/p/zxing/) provides a decoder implementation in both Java and C++. In theory, it should be possible to link the C++ library as a php extension, though I don't know anything of the mechanics of that. I've done it for Ruby ...
zxing ( http://code.google.com/p/zxing/) 提供了 Java 和 C++ 中的解码器实现。从理论上讲,应该可以将 C++ 库链接为 php 扩展,尽管我对它的机制一无所知。我已经为 Ruby 做到了...
Moreover, zxing does have an online decoder at http://zxing.org/w/decode.jspx. My thinking is that from PHP you can take the image and post it to the webservice and retrieve the decoded data. I don't know the mechanics of making remote web service calls from PHP and how different hosting environments might limit that, though, but it seems reasonable?
此外,zxing 在http://zxing.org/w/decode.jspx确实有一个在线解码器。我的想法是,您可以从 PHP 获取图像并将其发布到网络服务并检索解码后的数据。我不知道从 PHP 进行远程 Web 服务调用的机制以及不同的托管环境可能会如何限制它,但这似乎是合理的?
回答by Perry
If you have the possibility to use a phpextension, php-zbarcode at https://github.com/mkoppanen/php-zbarcodecan read qrcodes. It's a wrapper for ZBar from http://zbar.sourceforge.net, which in turn is a LGPL C library for decoding barcodes.
如果您有可能使用 phpextension,https://github.com/mkoppanen/php-zbarcode 上的 php-zbarcode可以读取 qrcodes。它是来自http://zbar.sourceforge.net 的ZBar 的包装器,它又是一个用于解码条形码的 LGPL C 库。
回答by Huzoor Bux
To decode your QR code you have to upload image of QR code and it will show you text inside that code image.
要解码您的 QR 码,您必须上传 QR 码的图像,它会在该代码图像中显示文本。
http://www.phpgang.com/how-to-decode-qr-code_344.html
http://www.phpgang.com/how-to-decode-qr-code_344.html
Very easy to do tutorial I hope it helps.
很容易做教程我希望它有帮助。
回答by Niko Jojo
Here is a good example & you can generate online direct QR code too...
这是一个很好的例子,您也可以生成在线直接二维码...
there is also php library to implement QR code in your project.
还有 php 库可以在您的项目中实现二维码。