A simple QR Code generator, using https://github.com/skip2/go-qrcode/
This is LARGELY based on the sample CLI from go-qrcode (above), but takes input from stdin, and infers how the output should look (based on whether this is run from a terminal or not).
$ go get -u github.com/stensonb/qrcode
A command-line tool qrcode
will be built into $GOPATH/bin/
.
$ qrcode -h
qrcode -- QR Code encoder in Go
https://github.com/stensonb/qrcode
Flags:
-d disable QR Code border
-i invert black and white
-s int
image size (pixel) (default 256)
-t print as text-art on STDOUT (default true)
Data read from STDIN, and written to STDOUT. If STDOUT is a terminal device, print as text-art.
If STDOUT is not a terminal (unix pipe, for example), create a PNG image and write to STDOUT.
Usage:
1. Output a text-art QR code to the terminal:
echo "hello world" | qrcode
2. Save a PNG image to file:
echo "hello world" | qrcode > out.png
3. Pipe PNG image to 'display' (on any X server):
echo "hello world" | qrcode | display
4. Force output to PNG image (just the bytes), when writing to a terminal-based STDOUT:
echo "hello world" | qrcode -t=false
The maximum capacity of a QR Code varies according to the content encoded and the error recovery level. The maximum capacity is 2,953 bytes, 4,296 alphanumeric characters, 7,089 numeric digits, or a combination of these.
To aid QR Code reading software, QR codes have a built in whitespace border.
If you know what you're doing, and don't want a border, see https://gist.github.com/skip2/7e3d8a82f5317df9be437f8ec8ec0b7d for how to do it. It's still recommended you include a border manually.
- http://en.wikipedia.org/wiki/QR_code
- ISO/IEC 18004:2006 - Main QR Code specification (approx CHF 198,00)
- https://github.com/skip2/go-qrcode/ - library used here