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.

Synopsis:

usage: qr2text [-h] [--version] [--black-background] [--white-background]
               [--big] [--trim] [--pad PAD] [--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
  --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.0.tar.gz (13.5 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.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qr2text-1.0.0.tar.gz
  • Upload date:
  • Size: 13.5 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.0.tar.gz
Algorithm Hash digest
SHA256 b3e03f0296db617bb42eae685cfc2b28cd273649d068c8f4f2863eab5d25bb87
MD5 a0100667c1324627924b2ab3903128a9
BLAKE2b-256 c80591ed27a7e21c643021946ee64fdf1e53a1d612e9babec485a493d3b24328

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qr2text-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6eac419e897ae7ca8b4b2d0033b96156eecbc38025fb0ae1f45098de6343c4f1
MD5 43316f940f5fe9ad67b6d7ca01e24785
BLAKE2b-256 5850ea6c0a46f0f0dac6148c3ce654e457d850508546b70cbdd4dfd52d212160

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