https://github.com/mgedmin/qr2text
Convert PyQRCode generated SVG to ASCII art
https://github.com/mgedmin/qr2text
code qr svg
Last synced: 10 months ago
JSON representation
Convert PyQRCode generated SVG to ASCII art
- Host: GitHub
- URL: https://github.com/mgedmin/qr2text
- Owner: mgedmin
- Created: 2022-01-20T12:29:44.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-01-20T12:23:12.000Z (about 1 year ago)
- Last Synced: 2025-04-10T04:04:39.181Z (10 months ago)
- Topics: code, qr, svg
- Language: Python
- Homepage: https://pypi.org/project/qr2text/
- Size: 49.8 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
Awesome Lists containing this project
README
qr2text
=======
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).
.. [[[cog
.. import cog, subprocess, textwrap, os
.. os.environ['COLUMNS'] = '80' # consistent line wrapping
.. helptext = subprocess.run(['qr2text', '--help'],
.. capture_output=True, text=True).stdout
.. cog.outl('\nSynopsis::\n')
.. cog.outl(textwrap.indent(helptext, ' '))
.. # Run `tox -e cog-apply` to re-generate the README.
.. ]]]
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
.. [[[end]]]