Skip to main content

Convert PyQRCode generated SVG to ASCII art

Project description

Convert SVG images containing barcodes generated by PyQRCode to ASCII art, for displaying in a terminal.

Because I’m a weird person who reads mail using Mutt over SSH in a terminal, and sometimes people send me QR codes for setting up TOTP authentication.

Example:

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

$ qr2text --white-background hello.svg


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


Hello world!

Note: you may have to tell qr2text whether your terminal is black-on-white (–white-background) or white-on-black (–black-background). Some QR code scanners don’t care, but others will refuse to recognize inverted QR codes.

Note: for QR code decoding to work you need to have libzbar installed on your system (e.g. sudo apt install libzbar0 on Ubuntu).

Synopsis:

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qr2text-1.1.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

qr2text-1.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file qr2text-1.1.0.tar.gz.

File metadata

  • Download URL: qr2text-1.1.0.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for qr2text-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f0ed6843a464c7bdeb1e6e4eeb37bd69708248e8a7f3eb5414f5ea8a120b47cd
MD5 88eedd0b18a1c7b563862bbcc7c61182
BLAKE2b-256 2c85e34a4ad80df38f72bcea7dd8e4ed26c9379e7d4c2789f89db8661b3bfcdb

See more details on using hashes here.

File details

Details for the file qr2text-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: qr2text-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for qr2text-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0aebe6a8bc698692329861512ea29784a92b65cf3dfa5337b7230477fa56e0bd
MD5 93474fc067f36c850c1fdb84be97bcd0
BLAKE2b-256 c6e1e5e3f5ab288d1e01b737696a515c50c68ac5bfb614a2e14bec2f3e715337

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page