【问题标题】:How can I get a QR code from an encrypted image? [closed]如何从加密图像中获取二维码? [关闭]
【发布时间】:2018-11-19 03:48:43
【问题描述】:

This is png image:

当我用记事本++打开它时,我发现这是一个二维码 如果python有解决这个问题的lib,如何恢复它?

【问题讨论】:

  • 为什么要先用notepad++打开一个png?
  • 因为提示建议我这样做。实际上,当我用浏览器打开它时,我从源代码中找到了一个 base64 代码,对其进行解码并且竞争是相同的

标签: python qr-code


【解决方案1】:

我不会说这是加密的,更像是以这样一种方式编码,即每个白色像素都应该是数字字符,而其他字符应该显示为黑色。这很容易解码,然后你可以使用你最喜欢的图像构建/操作库来重新创建图像。

这是一个使用简单pypng 模块的示例:

import png

with open("misc.png", "r") as f:  # open the file for reading and...
    # ... read the file line by line and store numbers as white and others as black pixels
    data = [[pixel.isdecimal() for pixel in line] for line in f]
png.from_array(data, "L", {"bitdepth": 1}).save("decoded.png")  # use pypng to save it as PNG

对于misc.png 中的链接数据,将产生decoded.png

【讨论】:

  • 哦,非常感谢
猜你喜欢
  • 1970-01-01
  • 2013-02-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-14
相关资源
最近更新 更多