Coder Social home page Coder Social logo

qrterminal's Introduction

QRCode Terminal

Build Status

A golang library for generating QR codes in the terminal.

Originally this was a port of the NodeJS version. Recently it's been updated to allow for smaller code generation using ASCII 'half blocks'

Example

Full size ASCII block QR Code:
alt text

Smaller 'half blocks' in the terminal:
alt text

Install

For command line usage see below, or grab the binary from the releases page

As a library in an application

go get github.com/mdp/qrterminal/v3

Usage

import (
    "github.com/mdp/qrterminal/v3"
    "os"
    )

func main() {
  // Generate a 'dense' qrcode with the 'Low' level error correction and write it to Stdout
  qrterminal.Generate("https://github.com/mdp/qrterminal", qrterminal.L, os.Stdout)
}

More complicated

Large Inverted barcode with medium redundancy and a 1 pixel border

import (
    "github.com/mdp/qrterminal/v3"
    "os"
    )

func main() {
  config := qrterminal.Config{
      Level: qrterminal.M,
      Writer: os.Stdout,
      BlackChar: qrterminal.WHITE,
      WhiteChar: qrterminal.BLACK,
      QuietZone: 1,
  }
  qrterminal.GenerateWithConfig("https://github.com/mdp/qrterminal", config)
}

HalfBlock barcode with medium redundancy

import (
    "github.com/mdp/qrterminal/v3"
    "os"
    )

func main() {
  config := qrterminal.Config{
      HalfBlocks: true,
      Level: qrterminal.M,
      Writer: os.Stdout,
  }
  qrterminal.GenerateWithConfig("https://github.com/mdp/qrterminal", config)
}

Command Line

Installation

OSX: brew install mdp/tap/qrterminal

Others: Download from the releases page

Source: go install github.com/mdp/qrterminal/v3/cmd/qrterminal@latest

Docker: docker pull ghcr.io/mdp/qrterminal:latest

Usage

Print out a basic QR code in your terminal:
qrterminal https://github.com/mdp/qrterminal

Using 'medium' error correction:
qrterminal https://github.com/mdp/qrterminal -l M

Or just use Docker: docker run --rm ghcr.io/mdp/qrterminal:latest 'https://github.com/mdp/qrterminal'

You can also pipe text via stdin

cat wireguard_peer.conf | qrterminal

or

cat wireguard_peer.conf | docker run --rm -i ghcr.io/mdp/qrterminal:latest

Contributors/Credits:

qrterminal's People

Contributors

akerl avatar calini avatar jqs7 avatar lx200916 avatar mattn avatar mdp avatar mtkennerly avatar sudo-suhas avatar taigrr avatar viric avatar windomz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

qrterminal's Issues

Sixel support fails in Xterm

Not actually sure if this is an issue with Xterm sixel support, or the detection, but in XTerm I'm getting back a blank line for the sixel version. Need to investigate more.

Add sixel support

Are you open to adding support for output in sixel format? Sixel is a format developed by DEC for printing graphics to a terminal attached printer. It was later used to display graphics on the terminals themselves. Several terminals including mlterm and xterm can support sixel graphics.

Although it is used to display graphics the format itself is text based and can be easily created using the same basic routines used by qrterminal to generate the text formats. I have a fork of qrterminal with sixel support and if you are interested in adding support will submit a PR.

My fork does make a significant change to qrterminal. Instead of adding another flag similar to the HalfBlocks to the Config struct I added a new Format entry. Format can currently be 1 of 3 defined constants, FullBlocks, HalfBlocks or Sixel. I implemented the change in a manner that will not break existing code. If Format is not set and Halfblocks is not true than a FullBlocks version will be generated. If HalfBlocks is true than a HalfBlocks version will be generated no matter the Format setting. If HalfBlocks is false and Format is set than the version specified by Format will be generated.

Issue in README

The sample code in the Readme doesn't work with a config. See attached PR fixing example code. #15

qr codes need 3 more pixels of border

Very nice project. I just wanted to point out that the QR spec says that the code itself must be placed in a 4-pixel-wide white border or "quiet zone", to help scanning software locate the code in a larger picture. The example on your front page only has a 1-pixel border, which may not be enough for some readers.

The most costly example I know of this bug is https://www.facebook.com/notes/facebook-engineering/a-hack-of-epic-proportions-building-a-qr-code-on-the-roof/10150630641218920/, in which Facebook engineers put a QR code on the roof of their new building. Unfortunately they did not include enough white border around the code, with the result that many readers I tried back in 2012 could not recognize the code in the image.

Generate half size QR-Codes with prebuild binary

Am I missing something, or is it not possible with the prebuild version to generate qr codes with half size? Would it be possible to add this feature, or should the feature be reserved for the library usage?

Use quarter size ascii blocks (the conway's game of life type)

You could use the "Conway's Game of Life" ASCII character set:
https://en.wikipedia.org/wiki/Block_Elements#Compact_table

| ▌| ▐ | ▖ | ▗ | ▘ | ▙ | ▚ | ▛ | ▜ | ▝ | ▞ | ▟ | █ | ▄ | ▀ |
  • upper half block
  • lower half block
  • right half block (renders incorrectly on github if not in code block)
  • left half block (same as above)
  • whole block
  • empty block (em quad shown since github doesn't show spaces in empty inline code blocks)
  • the two kitty-corner quadrants
  • the four exclusive corner quadrants
  • the four inclusive corner quadrants
▐ ▖▗▘▙▚▛▜▝▞▟█▄▀▌
▐ ▖▗▘▙▚▛▜▝▞▟█▄▀▌

Note: the terminal won't have the gap.

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.