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]
               filename [filename ...]

Convert PyQRCode SVG images to ASCII art

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

optional arguments:
  -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

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.0.1.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qr2text-1.0.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qr2text-1.0.1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.0.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.7

File hashes

Hashes for qr2text-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ef087a9edf204c04f28794b14545c1c69fac95448fc15975f9b709cc18755956
MD5 6be7b66053de6c928527b9f6ce0e7d69
BLAKE2b-256 b026f36d92adddd78ce769a06f3b6f01c792a8b23689dbe785d65fe75a2485ad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qr2text-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.0.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.7

File hashes

Hashes for qr2text-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c0d68bf3db1c1aeefa57b8bc52139b8719fa2e5b6c5b825d3c1efd8997087c1
MD5 6665be01e1f637cf1994145c19a2a8a3
BLAKE2b-256 08d4fd91b6a5300e48ad73248de777629aac8ea58cdd39655f11af1544795803

See more details on using hashes here.

Supported by

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