Code Monkey home page Code Monkey logo

qr's Introduction

qr

qr is a library for generating QR Codes in pure Go.

go get github.com/AlexEidt/qr

Usage

qrcode, err := qr.NewQRCode("QR Code", &qr.Options{Error: "H"})
if err != nil {
    panic(err)
}

qrcode.Render("qr.png", 10)

Below are the functions available for a QRCode.

qr.NewQRCode(data string, options *qr.Options) (*qr.QRCode, error)

Version() int
Mode() int // 1: numeric, 2: alphanumeric, 4: byte
ErrorLevel() string // L, M, Q, H
Bitmap() *qr.Bitmap
Render(filename string, scale int) error // .png, .jpg, .svg supported

Options

When building a QR Code, certain parameters can be specified such as the Version, Mode and Error Correction Level.

type Options struct {
	Version int
	Mode    int
	Error   string
}
Parameter Description
Version The version of the QR Code to be generated. Must be between 1 and 40. Defaults to lowest version that fits the given data.
Mode The mode of the QR Code to be generated. Must be qr.Numeric, qr.AlphaNum, or qr.Byte. The best fit is found based on the given data. See the Supported Modes section below for the characters that can be used in each mode.
Error The error correction level of the QR Code to be generated. Must be L, M, Q, or H. Defaults to L. Level L can correct ~7% of errors, M can correct ~15% of errors, Q can correct ~25% of errors, and H can correct ~30% of errors.

Supported Modes

Currently, only Numeric, Alphanumeric and Binary modes are supported for data encoding.

Mode Character Set
Numeric 0123456789
Alphanumeric 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:
Binary ISO/IEC 8859-1

Notes

  • Kanji mode is not supported.
  • Structured Append mode is not supported.
  • Extended Channel Interpretations (ECI) mode is not supported.
  • Model 1 QR Codes are not supported.

Acknowledgements

The following resources were helpful in building this library:

qr's People

Contributors

alexeidt avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.