使用ZXing解码QR码

时间:2014-05-26 21:40:05

标签: image decode qr-code zxing

我正在研究Js,我需要解码一些存储在PC上的图片的QR码,而不是上传到服务器上。我知道如何通过ZXing URL解码代码,例如:

http://zxing.org/w/decode?u=http://www.qrstuff.com/images/sample.png

所以,我可以创建一个XMLHttpRequest并解决了!但问题是我在计算机上有图像,我想避免将它们上传到服务器中。

我尝试做这样的事情,但它不起作用:

http://zxing.org/w/decode?u=file:///home/gal/Desktop/QR_code_demo.jpg

我还尝试使用image64字符串,但它也不起作用:

http://zxing.org/w/decode?u=url(data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAFoAWgMBIgACEQEDEQH/xAAcAAADAQEAAwEAAAAAAAAAAAAABQcGBAIDCAH/xAA7EAABAwQBAwIEAwQIBwAAAAABAgMEAAUGERIHITETIhQyQWEVQlEjgZHSJDM3VXF1krIWJVKCg6Gj/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/ALjRRU6zDKcrj5zHxvFo1sdU7AEomaFf9Sge4UPoB9KCi0VN/i+rv93Y1/qc/nr02nLM1j57aMdyiJaGm57brnKIFlWkoWR3KiB3T+lBTqKwkrPBi8mQxnTjEVTz61W/4Rpa+bAOgV63pX8K5HLp1NmLVKs8HH1214lyIt4rC1MnugqHLseJG6CjUVncPeyt1uV/xfHtzLgUn4f4Ekgjvy5bJ+1JupGUX6x3XH7bjjEF2RdXHm9TEqIBTw1ohQ18xoN3RU3+L6u/3djX+pz+euGZlnUKx3eyR8ghWJEa5T24u44Wp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2TrSaCm0UUUBU3mf29wf8iP+9dUipRmcu42PqxEvkawXO6RkWn0D8HHUsBRWvtsAj9O33oJZeOo2YMXaay1fpSW25DiUp9vYBRAHiqtc1qd6v4K44oqWq2uqUT9SWnKRuzrE84tx3pDeFLWoqUow17JPk+K7rbPuORdVMZuAxi72uFBjvMqVLjKSlO2nNe7Wh5AoPTZ7rm0LqI49kD0+Ni7cuRyelICGEt6WG9rI8b4a7/pTrqqxYXH7TkV0nQZDEBhx1q2OqT/zBKgNcST9Ox7A1jp7HUDK8pn43MfucWySpTyA89AJZS2kqUj3cR2PFIB39RW2zNi32qDY4Nzw+Xky48QNJeisKWG+ISDvW9b1v91BmLnbWOp0WysPJGJtxmyi2x5CQ58a2tKT+yG0dkhKfG/mHis9dz1MxX4mFClXZdotqS23KTG4t+kgfMOx0ND9TT6wwchuN2XksyFcY1vx1xSrZZnYRS4ppSSPTbOhvQSkeD4FdmVQs5vEu3MMXOc1asi5h6KYO/w5shPsdOt/mI768GgSYkLtEulqyKHk3x7dydaeyBLSU6iNp7j11AniNFfchPg1xycmks9anVWC5gwrlcorby460rQ+jaARvv27qHatTasFmYVCn2NKn7mMmb+DMqPFIRB0FJ5udz2/afb5aQOdKLjimR43MYkLuaDdGfV+HiKHopStJKlHZ0P8aD6EooooCiiigKKKKAooooCiiigKKKKAooooP//Z)

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

ZXing服务器必须能够读取图像,但可以从您的计算机上下载。

您可以在他们的网站上传图片(http://zxing.org/w/decode.jspx)。您可以使用处方集使用的URL。

这必须是对http://zxing.org/w/decode多部分/表单数据POST请求。

该文件在请求正文中发送。任何Ajax文件上传器都应该是好的。