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 {}
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