Coder Social home page Coder Social logo

qr2eascii's Introduction

QR-Code to E-ASCII

Generate a QR-code in E-ASCII-art using the black square symbol (█, U+2588, Alt+219). As input either an already generated picture of a QR-code or text can be used.

Requirements

$ (sudo) pip install -r requirements.txt

Usage

py convert.py [-h] [-i INPUT] [-o OUTPUT] [--invert] [-w WHITE] [-b BLACK] [-v VERSION] [--border BORDER] [-c {L,M,Q,H}]

  • -h, --help: Show help message.
  • -i INPUT: Input file path or text input (if not a valid path)
  • -o OUTPUT: Output file.
  • --invert: Invert colors.
  • -w WHITE: Characters for white pixel (default "██")
  • -b BLACK: Characters for black pixel (default "  ")
  • -v VERSION: QR-Code version (default 1)
  • --border BORDER: Border size of generated QR-Code (default 1)
  • -c [L,M,Q,H]: Error correction mode (default M)

If no input file is given, the program reads the data from stdin.

Notes when converting images

The conversion of images will only work reliably on pure black/white QR-codes with square eyes and dots. The border around the code should also be uniform for the scaling to work correctly. Codes that work can be generated with websites like qr-code-generator.com.


Example

From text

py convert.py --invert
> Enter data to encode: github.com/jojodicus

yields:

██████████████████████████████████████████████████████
██              ████      ██    ██████              ██
██  ██████████  ██  ██  ██    ████  ██  ██████████  ██
██  ██      ██  ██      ██████    ████  ██      ██  ██
██  ██      ██  ██  ████████  ██    ██  ██      ██  ██
██  ██      ██  ████  ██  ████  ██  ██  ██      ██  ██
██  ██████████  ████████  ████  ██████  ██████████  ██
██              ██  ██  ██  ██  ██  ██              ██
██████████████████      ██  ██  ██  ██████████████████
██  ██████████  ██  ██            ██    ████      ████
██  ██    ██  ████████    ██████  ██████          ████
██  ████        ██████  ████  ██      ██      ██    ██
██  ██        ██  ██  ████████                ██    ██
████████  ████    ██  ██████    ██        ██  ██  ████
██      ██████████████  ██    ██    ████  ████  ██████
██  ██              ████████      ██  ██      ██    ██
██  ████      ██    ██████            ████        ████
██  ██  ██  ██  ██████  ██  ██  ██          ██      ██
██████████████████  ██  ██████████  ██████    ████████
██              ██████████      ██  ██  ██  ██  ██  ██
██  ██████████  ██████    ████      ██████    ████  ██
██  ██      ██  ██████    ██████                    ██
██  ██      ██  ████  ████    ██  ██    ██████      ██
██  ██      ██  ████    ████    ██  ████  ██    ██  ██
██  ██████████  ████    ██    ████  ██████  ██████  ██
██              ██  ████      ████    ██████  ████  ██
██████████████████████████████████████████████████████

py convert.py -i example/qr-code.png -o example/qr-code.txt --invert

see example/qr-code.png and example/qr-code.txt

yields:

████████████████████████████████████████████████████████████████
████████████████████████████████████████████████████████████████
████              ██████████  ██    ██  ██████              ████
████  ██████████  ██    ██  ██  ██    ████████  ██████████  ████
████  ██      ██  ██  ██          ██████  ████  ██      ██  ████
████  ██      ██  ██    ████  ████    ██    ██  ██      ██  ████
████  ██      ██  ████  ██    ██    ██      ██  ██      ██  ████
████  ██████████  ████      ████  ████████  ██  ██████████  ████
████              ██  ██  ██  ████  ██  ██  ██              ████
████████████████████  ██████████    ██      ████████████████████
████  ██████████  ██      ████████    ██  ██    ████      ██████
████      ██  ██████  ██        ██        ██  ██    ██    ██████
████    ████████    ████████        ██  ██████████  ████████████
████████  ████  ████    ██  ██  ████████  ██  ██████  ██████████
██████████        ██████  ██        ██████  ██    ████████  ████
████  ████  ██████    ████  ██████  ██  ██  ██      ████    ████
████    ██████  ██  ██  ████████  ██████  ██████    ██  ██  ████
██████████  ████  ████        ████    ██  ██  ██  ██    ████████
████  ████████  ██    ██    ██  ████████  ████      ██      ████
████    ██        ██    ██  ████  ██  ██  ████████    ████  ████
████  ████████████  ████    ██  ██████████  ██  ████████████████
████  ██████        ██      ████  ██  ██            ██      ████
████████████████████  ██  ██  ████████████  ██████    ██████████
████              ████  ████  ██████        ██  ██      ████████
████  ██████████  ████  ██    ██    ████    ██████  ████████████
████  ██      ██  ████  ██  ██  ████                  ██████████
████  ██      ██  ██████    ██  ████          ██████      ██████
████  ██      ██  ████  ████          ██                  ██████
████  ██████████  ████  ████  ████      ██████    ██    ██  ████
████              ██        ████  ██████  ████      ██  ████████
████████████████████████████████████████████████████████████████
████████████████████████████████████████████████████████████████

qr2eascii's People

Contributors

jojodicus avatar soft-coded avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.