gqrcode

command module
v0.0.0-...-6b448be Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2021 License: MIT Imports: 6 Imported by: 0

README

QR Code(Quick Response Code) Implement by Go

The QRCode Generator, Micro QRCode Generator, QRCode Decoder, Micro QRCode Decoder application.

According to ISO/IEC 18004-2015 Standard

Installation

go get -u github.com/KangSpace/gqrcode

Dependencies Package:

  1. imaging

go get -u github.com/disintegration/imaging

  1. image

mkdir $GOPATH/golang.org/x/
cd $GOPATH/golang.org/x/
git clone https://github.com/golang/image.git

  1. text

cd $GOPATH/golang.org/x/
git clone https://github.com/golang/text.git

Usage

QR Code

QRCode supports 4 character modes, and 40 versions with 4 Error correction levels.

Micro QRCode supports 4 character modes, and 4 versions with 4 Error correction levels.

4 Modes:

  • numeric
    characters(10): 0 - 9

    maximum characters in Version 40-L: 7089 characters.

  • alphanumeric
    characters(45): 0 - 9, A - Z, SP, $, %, *, +, -, ., /, :

    maximum characters in Version 40-L: 4296 characters.

    Alphanumeric mode is not available in Version M1 Micro QR Code Symbol

  • byte
    8-bit characters.

    maximum characters in Version 40-L: 2953 characters.

    Byte mode is not available in Version M1 or M2 Micro QR Code Symbol.

  • kanji
    Kanji characters in accordance with the Shift JIS system based on JIS X 0209. Only use for double-byte characters, Range are: \x8140-\x9FFC and \xE040-\xEBBF.

    maximum characters in Version 40-L: 2953 characters.

    Kanji mode is not available in Version M1 Or M2 Micro QR Code Symbol.

4 Error correction level:
Four levels of Reed-Solomon error correction(referred to as L, M, Q and H in increasing order of capacity) allowing recover of:

  • L 7%
  • M 15%
  • Q 25%
  • H 30%

    Micro QR Code is not support H level.

Create QR Code
    // create a numeric qrcode
    data := "0123456"
    qrcode, err := NewQRCode(data)   
    outFileName := "/opt/temp/numeric.png"
    if err == nil{
        out := output.NewPNGOutput0()
        qrcode.Encode(out,outFileName)
    }
    
    // create a numeric micro qrcode
    micQrcode, err := NewMicroQRCode(data)   
    outFileName2 := "/opt/temp/numeric_micro.png"
    if err == nil{
        out2 := output.NewPNGOutput0()
        micQrcode.Encode(out2,outFileName2)
    }
Encode QR Code
   out := output.NewPNGOutput0()
   qrcode.Encode(out,outFileName)

Encode Params:

Parameter Type Values Comments
out output.Output NewPNGOutput(size int), NewPNGOutput0(), NewJPGOutput(size int), NewJPGOutput0(), NewGIFOutput(size int), NewGIFOutput0() Newxxx0() output with auto-size for image.
fileName string output file path -
Output QRCode

output.ImageOutput implements output.Output interface to output PNG,JPG,GIF image.

    out := output.NewPNGOutput(100)
    out = output.NewPNGOutput0()
  
    logoImageFilePath := "logo.png"
    // add logo image into QRCode
    out.AddOption(output.LogoOption(logoImageFilePath))

Output Params:

Parameter Type Values Comments
size int the image size for output -
Test QR Code

All QRCode test in qrcode_test.go and micro_qrcode_test.go files.

TODO list
Type Item Done Time
QRCode Model2 Numeric Mode and test 2021-05-30 22:47:57
Alphanumeric Mode 2021-05-31
Byte Mode 2021-05-31
Kanji Mode 2021-06-01
ECI Mode NOT-IMPLEMENT
FNC1 Mode NOT-IMPLEMENT
Mixed Mode NOT-IMPLEMENT
QRCode Model1 - NOT-SUPPORT
Micro QRCode Micro QRCode 2021-06-07
Personalized QRCode
(add logo image at center of QRCode)
- 2021-06-02
Output Image File 2021-05-30
Base64 String 2021-06-01
SVG -
Decoder QRCode -
Micro QRCode -

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
core

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL