跳转到主要内容

将PyQRCode生成的SVG转换为ASCII艺术

项目描述

将PyQRCode生成的包含条形码的SVG图像转换为ASCII艺术,用于在终端中显示。

因为我是一个奇怪的人,在终端中使用Mutt通过SSH阅读邮件,有时人们会给我发送用于设置TOTP身份验证的二维码。

示例

$ python3
>>> import pyqrcode
>>> qr = pyqrcode.create('Hello world!')
>>> qr.svg('hello.svg')

$ qr2text --white-background hello.svg


    █▀▀▀▀▀█ ▀▄█▄▀▄▀▀▄ █▀▀▀▀▀█
    █ ███ █ ▀ █▄  █   █ ███ █
    █ ▀▀▀ █ ▀▀▄▄▀ ▀ ▄ █ ▀▀▀ █
    ▀▀▀▀▀▀▀ █▄█▄▀▄▀▄▀ ▀▀▀▀▀▀▀
     ▄▄▄▄▀▀ ▄▀▄▀██▀▀▀ ▀▄█▄▀ ▀
    ▀▀▀▀▀▄▀▀▄▀▄▀▄ ▀▀█▀▄ ▀█ ██
    ▄█▀▄▀ ▀▀▄  ▄██▄▀  ▀▄ █▄ ▀
    █   ▄ ▀▀▀█▄  ██▀█▀██▀█▄▀█
    ▀  ▀ ▀▀▀▄█▄▀▄█▀▀█▀▀▀███ ▄
    █▀▀▀▀▀█ ▄  █▀▄▀██ ▀ █   █
    █ ███ █  █▀▄ ▄  ▀▀█▀▀▀█▀▄
    █ ▀▀▀ █  ▄▀▀▀▀  ▀ ▄█▄█  █
    ▀▀▀▀▀▀▀  ▀ ▀▀  ▀▀ ▀ ▀   ▀


Hello world!

注意:你可能需要告诉qr2text你的终端是黑白(–white-background)还是黑白(–black-background)。一些二维码扫描器不在乎,但其他一些将拒绝识别反转的二维码。

注意:要使二维码解码工作,你需要在你的系统上安装libzbar(例如,在Ubuntu上使用sudo apt install libzbar0)。

概要

usage: qr2text [-h] [--version] [--black-background] [--white-background]
               [--big] [--trim] [--pad PAD] [--decode] [--no-decode]
               [--encode-text ENCODE_TEXT]
               [filename ...]

Convert PyQRCode SVG images to ASCII art

positional arguments:
  filename              SVG file with the QR code (use - for stdin)

options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --black-background    terminal is white on black (default)
  --white-background, --invert
                        terminal is black on white
  --big                 use full unicode blocks instead of half blocks
  --trim                remove empty border
  --pad PAD             pad with empty border
  --decode              decode the QR codes (default if libzbar is available)
  --no-decode           don't decode the QR codes
  --encode-text ENCODE_TEXT
                        generate a QR code with given text

项目详情


下载文件

下载适用于您平台的应用程序。如果您不确定选择哪个,请了解更多关于 安装软件包 的信息。

源代码发行版

qr2text-1.1.0.tar.gz (14.3 kB 查看哈希值)

上传于 源代码

构建分发

qr2text-1.1.0-py3-none-any.whl (7.2 kB 查看哈希)

上传于 Python 3

由以下提供支持