Skip to main content

A library to display QR codes in console.

Project description

QRConsole

A library to display QR codes in console.

Requirements

Pillow>=7.0.0 - Download using python or python3 -m pip install "Pillow>=7.0.0"

Installation

PyPI

To get the module through PyPi: pip install qrconsole.

GitHub (Pulled Repo)

To install the module by pulling the repo: python setup.py install.

How to use

QRConsole is pretty straight-forward. Provide an image, and it will return a string with the console-ified version.
The image provided must be black-and-white. If there are greys, they will be turned into white or black depending on which they are closer to.
A good site for creation is this one, since there is no rounding or styling, just b&w pixels.
It is recommended to keep the images as small as possible, since every pixel of the image is two characters in the console. The example image is 65x65 px.

Use

In a project

  1. Initialize
from qrconsole import QRConsole
qr = QRConsole(char="@") # char = The character to use for white in the QR Code. Must have a length of 1.
  1. Console-ify image
    There are two ways to do this. The first way is to provide a path to the image:
print(qr.consoleify(qr_img="path_to_code.png", resize_factor=1))
# `qr_img: str` - The path to the QR Code image.
# `resize_factor: float` - How much to shrink/grow the image by (`width/resize_factor`, `height/resize_factor`)

And the second way is to provide a Pillow Image object:

from PIL import Image
img = Image.open("path_to_code.png")
print(qr.consoleify(qr_img=img, resize_factor=1))
# `qr_img: Image` - A Pillow Image object.
# `resize_factor: float` - How much to shrink/grow the image by (`width/resize_factor`, `height/resize_factor`)

Some libraries (for example the qrcode library) can turn codes into Images natively, so this method would be easier to use to avoid unnecessary file-writing.

Through python -m

It is also possible to use QRConsole as a command line tool. After installing the package, run python or python3 -m qrconsole <image path> <resize factor (optional)>.

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

qrconsole-1.1.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

qrconsole-1.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qrconsole-1.1.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.4

File hashes

Hashes for qrconsole-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e0063df3b917df192ff06664cf03cdcd4f58e022d86e7bf35710198615806567
MD5 c5d57256209c18e7c63a19d5017f6bbd
BLAKE2b-256 740cdea5f0ae48d50a7ef0fcf093ef508c1cb17ccd03bdfdd93fa279945e89e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qrconsole-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.4

File hashes

Hashes for qrconsole-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ecc8013302e41708e2b09a2bf05f803b8530ee64ec152f85fc5a2070dcf56954
MD5 eb1d0c5cff7e196d203505988616d1fd
BLAKE2b-256 b1275ec59bd2d53e9c6ba69b1d816256ce6964bd3f044a69f325f10607d01270

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