MCPcopy Create free account
hub / github.com/skip2/go-qrcode / Encode

Function Encode

qrcode.go:74–84  ·  view source on GitHub ↗

Encode a QR Code and return a raw PNG image. size is both the image width and height in pixels. If size is too small then a larger image is silently returned. Negative values for size cause a variable sized image to be returned: See the documentation for Image(). To serve over HTTP, remember to se

(content string, level RecoveryLevel, size int)

Source from the content-addressed store, hash-verified

72//
73// To serve over HTTP, remember to send a Content-Type: image/png header.
74func Encode(content string, level RecoveryLevel, size int) ([]byte, error) {
75 var q *QRCode
76
77 q, err := New(content, level)
78
79 if err != nil {
80 return nil, err
81 }
82
83 return q.PNG(size)
84}
85
86// WriteFile encodes, then writes a QR Code to the given filename in PNG format.
87//

Callers 1

TestExampleEncodeFunction · 0.70

Calls 2

PNGMethod · 0.95
NewFunction · 0.70

Tested by 1

TestExampleEncodeFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…