You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # go-qrcode #
  2. <img src='https://skip.org/img/nyancat-youtube-qr.png' align='right'>
  3. Package qrcode implements a QR Code encoder. [![Build Status](https://travis-ci.org/skip2/go-qrcode.svg?branch=master)](https://travis-ci.org/skip2/go-qrcode)
  4. A QR Code is a matrix (two-dimensional) barcode. Arbitrary content may be encoded, with URLs being a popular choice :)
  5. 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.
  6. ## Install
  7. go get -u github.com/skip2/go-qrcode/...
  8. A command-line tool `qrcode` will be built into `$GOPATH/bin/`.
  9. ## Usage
  10. import qrcode "github.com/skip2/go-qrcode"
  11. - **Create a PNG image:**
  12. var png []byte
  13. png, err := qrcode.Encode("https://example.org", qrcode.Medium, 256)
  14. - **Create a PNG image and write to a file:**
  15. err := qrcode.WriteFile("https://example.org", qrcode.Medium, 256, "qr.png")
  16. - **Create a PNG image with custom colors and write to file:**
  17. err := qrcode.WriteColorFile("https://example.org", qrcode.Medium, 256, color.Black, color.White, "qr.png")
  18. All examples use the qrcode.Medium error Recovery Level and create a fixed
  19. 256x256px size QR Code. The last function creates a white on black instead of black
  20. on white QR Code.
  21. The maximum capacity of a QR Code varies according to the content encoded and
  22. the error recovery level. The maximum capacity is 2,953 bytes, 4,296
  23. alphanumeric characters, 7,089 numeric digits, or a combination of these.
  24. ## Documentation
  25. [![godoc](https://godoc.org/github.com/skip2/go-qrcode?status.png)](https://godoc.org/github.com/skip2/go-qrcode)
  26. ## Demoapp
  27. [http://go-qrcode.appspot.com](http://go-qrcode.appspot.com)
  28. ## CLI
  29. A command-line tool `qrcode` will be built into `$GOPATH/bin/`.
  30. ```
  31. qrcode -- QR Code encoder in Go
  32. https://github.com/skip2/go-qrcode
  33. Flags:
  34. -o string
  35. out PNG file prefix, empty for stdout
  36. -s int
  37. image size (pixel) (default 256)
  38. Usage:
  39. 1. Arguments except for flags are joined by " " and used to generate QR code.
  40. Default output is STDOUT, pipe to imagemagick command "display" to display
  41. on any X server.
  42. qrcode hello word | display
  43. 2. Save to file if "display" not available:
  44. qrcode "homepage: https://github.com/skip2/go-qrcode" > out.png
  45. ```
  46. ## Links
  47. - [http://en.wikipedia.org/wiki/QR_code](http://en.wikipedia.org/wiki/QR_code)
  48. - [ISO/IEC 18004:2006](http://www.iso.org/iso/catalogue_detail.htm?csnumber=43655) - Main QR Code specification (approx CHF 198,00)<br>
  49. - [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)