|
2 | 2 |
|
3 | 3 | <img src='https://skip.org/img/nyancat-youtube-qr.png' align='right'>
|
4 | 4 |
|
5 |
| -Package qrcode implements a QR Code encoder. [](https://travis-ci.org/skip2/go-qrcode) <br> |
6 |
| - |
7 |
| -<br> |
8 |
| -A QR Code is a matrix (two-dimensional) barcode. Arbitrary content may be encoded, with URLs being a popular choice :)<br> |
9 |
| -<br> |
10 |
| -Each QR Code contains error recovery information to aid reading damaged or obscured codes. There are four levels of error recovery: Low, medium, high and highest. QR Codes with a higher recovery level are more robust to damage, at the cost of being physically larger.<br> |
11 |
| -<br> |
12 |
| -<h1>Usage</h1> |
13 |
| -<pre>import qrcode "github.com/skip2/go-qrcode" |
14 |
| -</pre> |
15 |
| - |
16 |
| -<ul><li><b>Create a PNG image:</b><pre>var png []byte |
17 |
| -png, err := qrcode.Encode("https://example.org", qrcode.Medium, 256) |
18 |
| -</pre></li></ul> |
19 |
| - |
20 |
| -<ul><li><b>Create a PNG image and write to a file:</b> |
21 |
| -<pre>err := qrcode.WriteFile("https://example.org", qrcode.Medium, 256, "qr.png") |
22 |
| -</pre></li></ul> |
23 |
| - |
24 |
| -Both examples use the <code>qrcode.Medium</code> error Recovery Level and create a 256x256 pixel, black on white QR Code.<br> |
25 |
| -<br> |
26 |
| -The maximum capacity of a QR Code varies according to the content encoded and<br> |
27 |
| -the error recovery level. The maximum capacity is 2,953 bytes, 4,296<br> |
28 |
| -alphanumeric characters, 7,089 numeric digits, or a combination of these.<br> |
29 |
| -<br> |
30 |
| -<h1>Documentation</h1> |
31 |
| - |
32 |
| -<a href='https://godoc.org/github.com/skip2/go-qrcode'><img src='https://godoc.org/github.com/skip2/go-qrcode?status.png' /></a> |
33 |
| - |
34 |
| -<h1>Demoapp</h1> |
35 |
| -<a href='http://go-qrcode.appspot.com'>http://go-qrcode.appspot.com</a> |
36 |
| - |
37 |
| -<h1>Links</h1> |
38 |
| - |
39 |
| -<ul><li><a href='http://en.wikipedia.org/wiki/QR_code'>http://en.wikipedia.org/wiki/QR_code</a> |
40 |
| -</li><li><a href='http://www.iso.org/iso/catalogue_detail.htm?csnumber=43655'>ISO/IEC 18004:2006</a> - Main QR Code specification (approx CHF 198,00)<br> |
41 |
| -</li><li><a href='https://github.com/qpliu/qrencode-go/'>https://github.com/qpliu/qrencode-go/</a> - alternative Go QR encoding library based on <a href='https://github.com/zxing/zxing'>ZXing</a> |
| 5 | +Package qrcode implements a QR Code encoder. [](https://travis-ci.org/skip2/go-qrcode) |
| 6 | + |
| 7 | +A QR Code is a matrix (two-dimensional) barcode. Arbitrary content may be encoded, with URLs being a popular choice :) |
| 8 | + |
| 9 | +Each QR Code contains error recovery information to aid reading damaged or obscured codes. There are four levels of error recovery: Low, medium, high and highest. QR Codes with a higher recovery level are more robust to damage, at the cost of being physically larger. |
| 10 | + |
| 11 | +## Install |
| 12 | + |
| 13 | + go get -u github.com/skip2/go-qrcode/... |
| 14 | + |
| 15 | +A command-line tool `qrcode` will be built into `$GOPATH/bin/`. |
| 16 | + |
| 17 | +## Usage |
| 18 | + |
| 19 | + import qrcode "github.com/skip2/go-qrcode" |
| 20 | + |
| 21 | +- **Create a PNG image:** |
| 22 | + |
| 23 | + var png []byte |
| 24 | + png, err := qrcode.Encode("https://example.org", qrcode.Medium, 256) |
| 25 | + |
| 26 | +- **Create a PNG image and write to a file:** |
| 27 | + |
| 28 | + err := qrcode.WriteFile("https://example.org", qrcode.Medium, 256, "qr.png") |
| 29 | + |
| 30 | +Both examples use the `qrcode.Medium` error Recovery Level and create a 256x256 pixel, black on white QR Code. |
| 31 | + |
| 32 | +The maximum capacity of a QR Code varies according to the content encoded and |
| 33 | +the error recovery level. The maximum capacity is 2,953 bytes, 4,296 |
| 34 | +alphanumeric characters, 7,089 numeric digits, or a combination of these. |
| 35 | + |
| 36 | +## Documentation |
| 37 | + |
| 38 | +[](https://godoc.org/github.com/skip2/go-qrcode) |
| 39 | + |
| 40 | +## Demoapp |
| 41 | + |
| 42 | +[http://go-qrcode.appspot.com](http://go-qrcode.appspot.com) |
| 43 | + |
| 44 | +## CLI |
| 45 | + |
| 46 | +A command-line tool `qrcode` will be built into `$GOPATH/bin/`. |
| 47 | + |
| 48 | +``` |
| 49 | +qrcode -- QR Code encoder in Go |
| 50 | +https://github.com/skip2/go-qrcode |
| 51 | +
|
| 52 | +Flags: |
| 53 | + -o string |
| 54 | + out PNG file prefix, empty for stdout |
| 55 | + -s int |
| 56 | + image size (pixel) (default 256) |
| 57 | +
|
| 58 | +Usage: |
| 59 | + 1. Arguments except for flags are joined by " " and used to generate QR code. |
| 60 | + Default output is STDOUT, pipe to imagemagick command "display" to display |
| 61 | + on any X server. |
| 62 | +
|
| 63 | + qrcode hello word | display |
| 64 | +
|
| 65 | + 2. Save to file if "display" not available: |
| 66 | +
|
| 67 | + qrcode "homepage: https://github.com/skip2/go-qrcode" > out.png |
| 68 | +``` |
| 69 | + |
| 70 | +## Links |
| 71 | + |
| 72 | +- [http://en.wikipedia.org/wiki/QR_code](http://en.wikipedia.org/wiki/QR_code) |
| 73 | +- [ISO/IEC 18004:2006](http://www.iso.org/iso/catalogue_detail.htm?csnumber=43655) - Main QR Code specification (approx CHF 198,00)<br> |
| 74 | +- [https://github.com/qpliu/qrencode-go/](https://github.com/qpliu/qrencode-go/) - alternative Go QR encoding library based on [ZXing](https://github.com/zxing/zxing) |
0 commit comments