Go实战--golang中生成读取二维码(skip2/go-qrcode和boombuler/barcode)
2017-09-08 17:43
2211 查看
生命不止,继续go go go!!!
这里介绍一下,golang如何生成二维码,当然是面向github编程了。
QR Code码,是由Denso公司于1994年9月研制的一种矩阵二维码符号,它具有一维条码及其它二维条码所具有的信息容量大、可靠性高、可表示汉字及图象多种文字信息、保密防伪性强等优点。
wiki:
QR code (abbreviated from Quick Response Code) is the trademark for a type of matrix barcode (or two-dimensional barcode) first designed for the automotive industry in Japan. A barcode is a machine-readable optical label that contains information about the item to which it is attached. A QR code uses four standardized encoding modes (numeric, alphanumeric, byte/binary, and kanji) to efficiently store data; extensions may also be used
star 211
获取:
生成二维码图片:
结果:
star 300
获取:
生成二维码图片:
结果:
star 13
获取:
读取二维码图片:
输出:
http://blog.csdn.net/wangshubo1989
这里介绍一下,golang如何生成二维码,当然是面向github编程了。
QRCode
百度百科:QR Code码,是由Denso公司于1994年9月研制的一种矩阵二维码符号,它具有一维条码及其它二维条码所具有的信息容量大、可靠性高、可表示汉字及图象多种文字信息、保密防伪性强等优点。
wiki:
QR code (abbreviated from Quick Response Code) is the trademark for a type of matrix barcode (or two-dimensional barcode) first designed for the automotive industry in Japan. A barcode is a machine-readable optical label that contains information about the item to which it is attached. A QR code uses four standardized encoding modes (numeric, alphanumeric, byte/binary, and kanji) to efficiently store data; extensions may also be used
skip2/go-qrcode生成二维码
github地址:https://github.com/skip2/go-qrcodestar 211
获取:
go get skip2/go-qrcode
生成二维码图片:
package main import qrcode "github.com/skip2/go-qrcode" import "fmt" func main() { err := qrcode.WriteFile("http://blog.csdn.net/wangshubo1989", qrcode.Medium, 256, "qr.png") if err != nil { fmt.Println("write error") } }
结果:
boombuler/barcode生成二维码
github地址:https://github.com/boombuler/barcodestar 300
获取:
go get github.com/boombuler/barcode
生成二维码图片:
package main import ( "image/png" "os" "github.com/boombuler/barcode" "github.com/boombuler/barcode/qr" ) func main() { qrCode, _ := qr.Encode("http://blog.csdn.net/wangshubo1989", qr.M, qr.Auto) qrCode, _ = barcode.Scale(qrCode, 256, 256) file, _ := os.Create("qr2.png") defer file.Close() png.Encode(file, qrCode) }
结果:
tuotoo/qrcode识别二维码
github地址:https://github.com/tuotoo/qrcodestar 13
获取:
go get github.com/tuotoo/qrcode
读取二维码图片:
package main import ( "fmt" "os" "github.com/tuotoo/qrcode" ) func main() { fi, err := os.Open("qrcode.png") if err != nil { fmt.Println(err.Error()) return } defer fi.Close() qrmatrix, err := qrcode.Decode(fi) if err != nil { fmt.Println(err.Error()) return } fmt.Println(qrmatrix.Content) }
输出:
http://blog.csdn.net/wangshubo1989
相关文章推荐
- Go实战--golang生成uuid(The way to go)
- java生成和解析二维码实战——QRCode
- Go实战--golang中各种排序算法实现以及生成随机数
- jquery-qrcode 生成和读取二维码
- Go实战--golang实现生成缩略图服务器(disintegration/imaging、nfnt/resize)
- iOS开发 - 二维码的生成与读取
- java生成二维码的三种方式zxing、qrcode以及jqueryqrcode
- Go实战--golang新手入门常见错误(The way to go)
- Go实战--golang中使用markdown(russross/blackfriday)
- Go实战--golang中使用MongoDB(mgo)
- 生成二维码(QRCode)图片加LOGO
- jquery-qrcode生成二维码
- Go实战--golang中文件以及文件夹路径相关操作
- Go_18: Golang 中三种读取文件发放性能对比
- QRCode - 二维码识别与生成
- Go实战--golang中使用echo框架中JSONP(labstack/echo)
- messagingtoolkit-qrcode(二维码生成类库)
- Python 的生成二维码生成库 -- qrcode
- 读取excel批量生成二维码
- Jquery插件-jquery-qrcode生成二维码