| 1 | # QRCode Terminal |
| 2 | |
| 3 | [](https://travis-ci.org/mdp/qrterminal) |
| 4 | |
| 5 | A golang library for generating QR codes in the terminal. |
| 6 | |
| 7 | Originally this was a port of the [NodeJS version](https://github.com/gtanner/qrcode-terminal). Recently it's been updated to allow for smaller code generation using ASCII 'half blocks' |
| 8 | |
| 9 | ## Example |
| 10 | Full size ASCII block QR Code: |
| 11 | <img src="https://user-images.githubusercontent.com/2868/37992336-0ba06b56-31d1-11e8-9d32-5c6bb008dc74.png" alt="alt text" width="225" height="225"> |
| 12 | |
| 13 | Smaller 'half blocks' in the terminal: |
| 14 | <img src="https://user-images.githubusercontent.com/2868/37992371-243d4238-31d1-11e8-92f8-e34a794b21af.png" alt="alt text" width="225" height="225"> |
| 15 | |
| 16 | ## Install |
| 17 | |
| 18 | For command line usage [see below](https://github.com/mdp/qrterminal#command-line), or grab the binary from the [releases page](https://github.com/mdp/qrterminal/releases) |
| 19 | |
| 20 | As a library in an application |
| 21 | |
| 22 | `go get github.com/mdp/qrterminal/v3` |
| 23 | |
| 24 | ## Usage |
| 25 | |
| 26 | ```go |
| 27 | import ( |
| 28 | "github.com/mdp/qrterminal/v3" |
| 29 | "os" |
| 30 | ) |
| 31 | |
| 32 | func main() { |
| 33 | // Generate a 'dense' qrcode with the 'Low' level error correction and write it to Stdout |
| 34 | qrterminal.Generate("https://github.com/mdp/qrterminal", qrterminal.L, os.Stdout) |
| 35 | } |
| 36 | ``` |
| 37 | |
| 38 | ### More complicated |
| 39 | |
| 40 | Large Inverted barcode with medium redundancy and a 1 pixel border |
| 41 | ```go |
| 42 | import ( |
| 43 | "github.com/mdp/qrterminal/v3" |
| 44 | "os" |
| 45 | ) |
| 46 | |
| 47 | func main() { |
| 48 | config := qrterminal.Config{ |
| 49 | Level: qrterminal.M, |
| 50 | Writer: os.Stdout, |
| 51 | BlackChar: qrterminal.WHITE, |
| 52 | WhiteChar: qrterminal.BLACK, |
| 53 | QuietZone: 1, |
| 54 | } |
| 55 | qrterminal.GenerateWithConfig("https://github.com/mdp/qrterminal", config) |
| 56 | } |
| 57 | ``` |
| 58 | |
| 59 | HalfBlock barcode with medium redundancy |
| 60 | ```go |
| 61 | import ( |
| 62 | "github.com/mdp/qrterminal/v3" |
| 63 | "os" |
| 64 | ) |
| 65 | |
| 66 | func main() { |
| 67 | config := qrterminal.Config{ |
| 68 | HalfBlocks: true, |
| 69 | Level: qrterminal.M, |
| 70 | Writer: os.Stdout, |
| 71 | } |
| 72 | qrterminal.Generate("https://github.com/mdp/qrterminal", config) |
| 73 | } |
| 74 | ``` |
| 75 | |
| 76 | |
| 77 | ## Command Line |
| 78 | |
| 79 | #### Installation |
| 80 | |
| 81 | OSX: `brew install mdp/tap/qrterminal` |
| 82 | |
| 83 | Others: Download from the [releases page](https://github.com/mdp/qrterminal/releases) |
| 84 | |
| 85 | Source: `go get -u github.com/mdp/qrterminal/v3/cmd/qrterminal` |
| 86 | |
| 87 | #### Usage |
| 88 | |
| 89 | Print out a basic QR code in your terminal: |
| 90 | `qrterminal https://github.com/mdp/qrterminal` |
| 91 | |
| 92 | Using 'medium' error correction: |
| 93 | `qrterminal https://github.com/mdp/qrterminal -l M` |
| 94 | |
| 95 | Or just use Docker: `docker run --rm mpercival/qrterminal:latest 'https://github.com/mdp/qrterminal'` |
| 96 | |
| 97 | ### Contributors/Credits: |
| 98 | |
| 99 | - [Mark Percival](https://github.com/mdp) |
| 100 | - [Matthew Kennerly](https://github.com/mtkennerly) |
| 101 | - [Viric](https://github.com/viric) |
| 102 | - [WindomZ](https://github.com/WindomZ) |
| 103 | - [mattn](https://github.com/mattn) |