pax_global_header 0000666 0000000 0000000 00000000064 15210512134 0014504 g ustar 00root root 0000000 0000000 52 comment=77e079951507352122a12a6a752fa9d18a1bddca
golang-github-yeqown-go-qrcode-2.2.5/ 0000775 0000000 0000000 00000000000 15210512134 0017437 5 ustar 00root root 0000000 0000000 golang-github-yeqown-go-qrcode-2.2.5/.github/ 0000775 0000000 0000000 00000000000 15210512134 0020777 5 ustar 00root root 0000000 0000000 golang-github-yeqown-go-qrcode-2.2.5/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 15210512134 0023162 5 ustar 00root root 0000000 0000000 golang-github-yeqown-go-qrcode-2.2.5/.github/ISSUE_TEMPLATE/bug_report.md 0000664 0000000 0000000 00000000766 15210512134 0025665 0 ustar 00root root 0000000 0000000 ---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: bug
assignees: yeqown
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Provide the minimum code snippet to help find out the cause.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Additional context**
Add any other context about the problem here.
golang-github-yeqown-go-qrcode-2.2.5/.github/ISSUE_TEMPLATE/feature_request.md 0000664 0000000 0000000 00000001166 15210512134 0026713 0 ustar 00root root 0000000 0000000 ---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE]"
labels: enhancement, help wanted
assignees: yeqown
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
golang-github-yeqown-go-qrcode-2.2.5/.github/ISSUE_TEMPLATE/question.md 0000664 0000000 0000000 00000000531 15210512134 0025352 0 ustar 00root root 0000000 0000000 ---
name: Question
about: Ask questions about this repository
title: "[QUESTION]"
labels: question
assignees: yeqown
---
**Describe the question what disturbed you**
A clear and concise description of the question.
**What solution you have tried**
Avoid others' duplicated trying.
**Additional context**
Any supplementary instruction here?
golang-github-yeqown-go-qrcode-2.2.5/.github/workflows/ 0000775 0000000 0000000 00000000000 15210512134 0023034 5 ustar 00root root 0000000 0000000 golang-github-yeqown-go-qrcode-2.2.5/.github/workflows/go.yml 0000664 0000000 0000000 00000002610 15210512134 0024163 0 ustar 00root root 0000000 0000000 name: Go
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19.2
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.48
build:
name: build-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19.2
stable: false
- name: Build
run: go build -v -race ./...
- name: Test qrcode
working-directory: .
run: go test -v -race ./...
continue-on-error: false
- name: Test writer/standard
working-directory: ./writer/standard
run: go mod tidy && mkdir testdata && go test -v -race ./...
continue-on-error: false
- name: Test writer/terminal
working-directory: ./writer/terminal
run: go mod tidy && mkdir testdata && go test -v -race ./...
continue-on-error: false
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
golang-github-yeqown-go-qrcode-2.2.5/.gitignore 0000664 0000000 0000000 00000000217 15210512134 0021427 0 ustar 00root root 0000000 0000000 vendor/
draft/
testdata/
js/
.idea/
.vscode/
# example/
*.png
default.jpeg
# *.json
*.log
.DS_store
tmp.png
go.sum
# Go Test
new.txt
old.txt golang-github-yeqown-go-qrcode-2.2.5/.issues/ 0000775 0000000 0000000 00000000000 15210512134 0021030 5 ustar 00root root 0000000 0000000 golang-github-yeqown-go-qrcode-2.2.5/.issues/go.mod 0000664 0000000 0000000 00000000213 15210512134 0022132 0 ustar 00root root 0000000 0000000 module issues
go 1.19
require (
github.com/yeqown/go-qrcode/v2 v2.2.2
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
)
golang-github-yeqown-go-qrcode-2.2.5/.issues/issue69/ 0000775 0000000 0000000 00000000000 15210512134 0022337 5 ustar 00root root 0000000 0000000 golang-github-yeqown-go-qrcode-2.2.5/.issues/issue69/issue69.go 0000664 0000000 0000000 00000007316 15210512134 0024204 0 ustar 00root root 0000000 0000000 /*
* Link: https://github.com/yeqown/go-qrcode/issues/69
* Title: Feature(image-compression): PNG bit depth must be 1
* Author: stokito(https://github.com/stokito)
*/
package main
import (
"fmt"
"image"
"image/png"
"io"
"os"
"strings"
skip2 "github.com/skip2/go-qrcode"
yeqown "github.com/yeqown/go-qrcode/v2"
yeqownwstd "github.com/yeqown/go-qrcode/writer/compressed"
)
/*
See https://github.com/yeqown/go-qrcode/issues/69
Results: (unit: B)
Content length: 158 // source text length
qr-skip2-best.png: 641 // skip2 generated size
qr-yeqown-best.png: 958 // yeqown best compression level
*/
func main() {
// some json
content := "{\n \"id\": \"beb6c04733d1a2da0f87c910a384\",\n \"tmax\": 895,\n \"cur\": [\n \"USD\"\n ],\n \"imp\": [\n {\n \"id\": \"21292\",\n \"instl\": 0,\n \"secure\": 0}\n"
// strip json to alpha num just for a test
content = strings.Replace(content, "{", "$", -1)
content = strings.Replace(content, "}", "%", -1)
content = strings.Replace(content, "\n", " ", -1)
content = strings.Replace(content, "\"", "*", -1)
content = strings.Replace(content, ",", "/", -1)
content = strings.Replace(content, "[", "/", -1)
content = strings.Replace(content, "]", "/", -1)
content = strings.ToUpper(content)
fmt.Printf("Content lenght: %d\n", len(content))
//imgEncoderNone := CustomPngEncoder{png.NoCompression}
imgEncoderBest := CustomPngEncoder{png.BestCompression}
encodeWithYeqown(content, "qr-yeqown.png")
//encodeWithYeqownCompression(content, "qr-yeqown-none.png", imgEncoderNone)
encodeWithYeqownCompression(content, "qr-yeqown-best.png", imgEncoderBest)
encodeWithSkip2(content, "qr-skip2-best.png")
}
func encodeWithSkip2(content, name string) {
//err := skip2.WriteFile(content, skip2.Highest, 0, name)
//if err != nil {
// log.Fatal(err)
//}
q, err := skip2.New(content, skip2.Highest)
if err != nil {
panic(err)
}
err = q.WriteFile(0, name)
if err != nil {
panic(err)
}
stat, _ := os.Stat(name)
fmt.Printf("%s: %v\n", name, stat.Size())
}
type CustomPngEncoder struct {
CompressionLevel png.CompressionLevel
}
func (j CustomPngEncoder) Encode(w io.Writer, img image.Image) error {
pngEncoder := png.Encoder{CompressionLevel: j.CompressionLevel}
return pngEncoder.Encode(w, img)
}
func encodeWithYeqown(content, name string) {
qrc, err := yeqown.NewWith(content,
yeqown.WithEncodingMode(yeqown.EncModeAlphanumeric),
yeqown.WithErrorCorrectionLevel(yeqown.ErrorCorrectionHighest),
)
if err != nil {
panic(err)
}
option := yeqownwstd.Option{
Padding: 4,
BlockSize: 1,
}
stdw, err := yeqownwstd.New(name, &option)
if err != nil {
panic(err)
}
if err := qrc.Save(stdw); err != nil {
panic(err)
}
stat, _ := os.Stat(name)
fmt.Printf("%s: %v\n", name, stat.Size())
}
func encodeWithYeqownCompression(content, name string, imageEncoder CustomPngEncoder) {
//cfg := yeqown.DefaultConfig()
//cfg.EncMode = yeqown.EncModeAlphanumeric
////cfg.EncMode = yeqown.EncModeByte
//cfg.EcLevel = yeqown.ErrorCorrectionHighest
//
//imgOpts := yeqown.WithCustomImageEncoder(imageEncoder)
//imgOpts2 := yeqown.WithQRWidth(1)
//imgOpts3 := yeqown.WithBorderWidth(4)
//qrc, err := yeqown.NewWithConfig(content, cfg, imgOpts, imgOpts2, imgOpts3)
//if err != nil {
// panic(err)
//}
qrc, err := yeqown.NewWith(content,
yeqown.WithEncodingMode(yeqown.EncModeAlphanumeric),
yeqown.WithErrorCorrectionLevel(yeqown.ErrorCorrectionHighest),
)
if err != nil {
panic(err)
}
option := yeqownwstd.Option{
Padding: 4,
BlockSize: 1,
}
stdw, err := yeqownwstd.New(name, &option)
if err != nil {
panic(err)
}
if err := qrc.Save(stdw); err != nil {
panic(err)
}
stat, _ := os.Stat(name)
fmt.Printf("%s: %v\n", name, stat.Size())
}
golang-github-yeqown-go-qrcode-2.2.5/LICENSE 0000664 0000000 0000000 00000002047 15210512134 0020447 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) 2018 yeqown
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
golang-github-yeqown-go-qrcode-2.2.5/Makefile 0000664 0000000 0000000 00000000636 15210512134 0021104 0 ustar 00root root 0000000 0000000 release: release-osx release-linux
release-osx:
- mkdir -p draft/osx
GOOS=darwin GOARCH=amd64 go build -o draft/osx/go-qrcode ./cmd/go-qrcode.go
cd draft/osx && tar -zcvf ../go-qrcode.osx.tar.gz .
release-linux:
- mkdir -p draft/linux
GOOS=linux GOARCH=amd64 go build -o draft/linux/go-qrcode ./cmd/go-qrcode.go
cd draft/linux && tar -zcvf ../go-qrcode.linux.tar.gz .
test-all:
go test -v --count=1 ./... golang-github-yeqown-go-qrcode-2.2.5/README.md 0000664 0000000 0000000 00000013114 15210512134 0020716 0 ustar 00root root 0000000 0000000 # go-qrcode #
[](https://goreportcard.com/report/github.com/yeqown/go-qrcode)
[](https://pkg.go.dev/github.com/yeqown/go-qrcode/v2)
[](https://github.com/yeqown/go-qrcode/actions/workflows/go.yml) 


[](./LICENSE)
QR code (abbreviated from Quick Response Code) is the trademark for a type of matrix barcode (or two-dimensional barcode) first designed in 1994 for the automotive industry in Japan. A barcode is a machine-readable optical label that contains information about the item to which it is attached. A QR code uses four standardized encoding modes (numeric, alphanumeric, byte/binary, and kanji) to store data efficiently; extensions may also be used
### Features
- [x] Normally generate QR code across `version 1` to `version 40`.
- [x] Automatically analyze QR version by source text.
- [x] Specifying cell shape allowably with `WithCustomShape`, `WithCircleShape` (default is `rectangle`)
- [x] Specifying output file's format with `WithBuiltinImageEncoder`, `WithCustomImageEncoder` (default is `JPEG`)
- [x] Not only shape of cell, but also color of QR Code background and foreground color.
- [x] `WithLogoImage`, `WithLogoImageFilePNG`, `WithLogoImageFileJPEG` help you add an icon at the central of QR Code.
- [x] `WithBorderWidth` allows to specify any width of 4 sides around the qrcode.
- [x] `WebAssembly` support, check out the [Example](./example/webassembly/README.md) and [README](cmd/wasm/README.md) for more detail.
- [x] support Halftone QR Codes, check out the [Example](./example/with-halftone).
### Install
```sh
go get -u github.com/yeqown/go-qrcode/v2
```
### Quick Start
link to [CODE](./example/main.go)
```go
package main
import (
"github.com/yeqown/go-qrcode/v2"
"github.com/yeqown/go-qrcode/writer/standard"
)
func main() {
qrc, err := qrcode.New("https://github.com/yeqown/go-qrcode")
if err != nil {
fmt.Printf("could not generate QRCode: %v", err)
return
}
w, err := standard.New("../assets/repo-qrcode.jpeg")
if err != nil {
fmt.Printf("standard.New failed: %v", err)
return
}
// save file
if err = qrc.Save(w); err != nil {
fmt.Printf("could not save image: %v", err)
}
}
```
### Options
```go
const (
// EncModeNone mode ...
EncModeNone encMode = 1 << iota
// EncModeNumeric mode ...
EncModeNumeric
// EncModeAlphanumeric mode ...
EncModeAlphanumeric
// EncModeByte mode ...
EncModeByte
// EncModeJP mode ...
EncModeJP
)
// WithEncodingMode sets the encoding mode.
func WithEncodingMode(mode encMode) EncodeOption {}
const (
// ErrorCorrectionLow :Level L: 7% error recovery.
ErrorCorrectionLow ecLevel = iota + 1
// ErrorCorrectionMedium :Level M: 15% error recovery. Good default choice.
ErrorCorrectionMedium
// ErrorCorrectionQuart :Level Q: 25% error recovery.
ErrorCorrectionQuart
// ErrorCorrectionHighest :Level H: 30% error recovery.
ErrorCorrectionHighest
)
// WithErrorCorrectionLevel sets the error correction level.
func WithErrorCorrectionLevel(ecLevel ecLevel) EncodeOption {}
```
following are some shots: