-
Normally generate QR code across
version 1
toversion 40
. -
Automatically analyze QR version by source text.
-
Specifying cell shape allowably with
WithCustomShape
,WithCircleShape
(default isrectangle
) -
Specifying output file's format with
WithBuiltinImageEncoder
,WithCustomImageEncoder
(default isJPEG
) -
Not only shape of cell, but also color of QR Code background and foreground color.
-
WithLogoImage
,WithLogoImageFilePNG
,WithLogoImageFileJPEG
help you add an icon at the central of QR Code.
go get -u github.com/yeqown/go-qrcode
link to CODE
package main
import (
"fmt"
qrcode "github.com/yeqown/go-qrcode"
)
func main() {
qrc, err := qrcode.New("https://github.com/yeqown/go-qrcode")
if err != nil {
fmt.Printf("could not generate QRCode: %v", err)
}
// save file
if err := qrc.Save("../testdata/repo-qrcode.jpeg"); err != nil {
fmt.Printf("could not save image: %v", err)
}
}
now go-qrcode
provides some options to customize output QRCode.
// WithBgColor background color
func WithBgColor(c color.Color) ImageOption {}
// WithBgColorRGBHex background color
func WithBgColorRGBHex(hex string) ImageOption {}
// WithFgColor QR color
func WithFgColor(c color.Color) ImageOption {}
// WithFgColorRGBHex Hex string to set QR Color
func WithFgColorRGBHex(hex string) ImageOption {}
// WithLogoImage .
func WithLogoImage(img image.Image) ImageOption {}
// WithLogoImageFilePNG load image from file, PNG is required
func WithLogoImageFilePNG(f string) ImageOption {}
// WithLogoImageFileJPEG load image from file, JPEG is required
func WithLogoImageFileJPEG(f string) ImageOption {}
// WithQRWidth specify width of each qr block
func WithQRWidth(width uint8) ImageOption {}
// WithCircleShape use circle shape as rectangle(default)
func WithCircleShape() ImageOption {}
// WithCustomShape use custom shape as rectangle(default)
func WithCustomShape(shape IShape) ImageOption {}
// WithBuiltinImageEncoder option includes: JPEG_FORMAT as default, PNG_FORMAT.
// This works like WithBuiltinImageEncoder, the different between them is
// formatTyp is enumerated in (JPEG_FORMAT, PNG_FORMAT)
func WithBuiltinImageEncoder(format formatTyp) ImageOption
// WithCustomImageEncoder to use custom image encoder to encode image.Image into
// io.Writer
func WithCustomImageEncoder(encoder ImageEncoder) ImageOption
use options in New
and NewWithSpecV
.
func New("text", WithQRWidth(x)) // x is uint8 (0 - 255)
following are some shots:
Jump to go.dev/github/yeqown/go-qrcode
go-qrcode's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.