自编码 QR 条形码?
我想知道是否可以以某种文件格式(例如 png)创建 QR,然后在 QR 中对 png 进行编码,这样生成的 QR 与您开始时使用的 QR 相同?
I was wondering if it's possible to create a QR in some file format, say png, then encode the png in QR, such that the resulting QR is the same one you started with?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不这么认为。每个 QR 码都需要对原始数据以及可变数量的冗余进行编码。
因此,要对原始 QR 码进行编码,您需要编码相同数量的信息和额外的冗余,这意味着结果不可能相同,因为它编码了更多信息。
I don't think so. Each QR code needs to encode the original data along with variable amounts of redundancy.
So to encode the original QR code, you need the encode the same amount of information and additional redundancies, which means the result can't be the same since it encodes more information.
QR 码有不同的尺寸,范围从 21x21 到 177x177。它们可以容纳 152 到大约 31,000 个数据位。不幸的是,即使每个“像素”使用 1 位,代码可以保存的数据量也永远不会达到存储它所需的位数。
有一些尺寸,但距离并不遥远。我想象一些简单的压缩算法,或者甚至忽略像校准区域这样的常见部分,可能会达到可以在其本身存储一些表示形式的程度。对我来说,你可以找到一种方法将某种大小的二维码存储为相同大小的二维码。
接下来的问题是构建一个能够自我创建的代码。通过不同的纠错选项,有空间可以捏造一些像素,这有助于提高这种事情发生的可能性,但它仍然需要相当多的魔法。也许某种遗传算法可以比暴力算法做得更好,但您可能需要阅读完整的规范并巧妙地手工构建一个。搜索空间相当大。
There are different sizes of QR codes ranging from 21x21 to 177x177. They can hold anywhere from 152 to around 31,000 data bits. Unfortunately, even using 1 bit per "pixel", the amount of data a code can hold never reaches the number of bits required to store it.
There are sizes, though for which it is not far off. I imagine some simple compression algorithm, or maybe even ignoring common parts like the calibration areas could get to a point where you can store some representation of it in itself. It is feasible to me that you could find a way to store a qr code of some size as a qr code of the same size.
The problem then is constructing a code which creates itself. With different error correction options, there is room to fudge a few pixels around, which helps the probability that such a thing is possible, but it would still take a fair bit of magic. Perhaps some sort of genetic algorithm could do better than brute force, but you may need to read the full spec and build one cleverly by hand. The search space is pretty big.
正如freespace提到的,由于多种原因,不可能在同一图像本身中对图像进行编码。
我创建了一个 QR 码,其中包含一个 URL,其中包含(再次)原始图像:
http://qr.ai/qqq< /a>
我真的认为这是你能得到的最接近的结果。
As freespace mentioned, it's not possible to encode an image in that same image itself, for several reasons.
I have created a QR Code which contains an URL which contains (again) the original image:
http://qr.ai/qqq
I really think that's the closest you can get.
一个 QR 码最多可以包含4296 个字符。我假设这是unicode,并且两个字节用于表示一个字符。这意味着一个QR码最多可以包含7089字节,足以存储一个小图像(就像一个小QR码)。
这里唯一的问题是,大多数二维码阅读器希望二维码包含文本(而不是图像数据)。
A QR code can contain max. 4296 characters. I assume this is unicode, and that two bytes are used to represent one character. This means that a QR code can contain a maximum of 7089 bytes, which is enough to store a small image (like a small qr code).
The only issue here, is that most QR readers expect qr-codes to contain text (not image data).