Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .issues/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ 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
github.com/yeqown/go-qrcode/v2 v2.2.5
github.com/yeqown/go-qrcode/writer/compressed v1.0.1
)

require github.com/yeqown/reedsolomon v1.0.0 // indirect
6 changes: 4 additions & 2 deletions cmd/qrcode/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ require (
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
github.com/fogleman/gg v1.3.0 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/nsf/termbox-go v1.1.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/yeqown/reedsolomon v1.0.0 // indirect
golang.org/x/image v0.18.0 // indirect
golang.org/x/image v0.24.0 // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
)

//replace (
Expand Down
3 changes: 2 additions & 1 deletion cmd/wasm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ require (
github.com/fogleman/gg v1.3.0 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/yeqown/reedsolomon v1.0.0 // indirect
golang.org/x/image v0.10.0 // indirect
golang.org/x/image v0.24.0 // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
)
2 changes: 0 additions & 2 deletions encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func newEncoder(m encMode, ec ecLevel, v version) *encoder {
// Encode ...
// 1. encode raw data into bitset
// 2. append _defaultPadding data
//
func (e *encoder) Encode(byts []byte) (*binary.Binary, error) {
e.dst = binary.New()
e.data = byts
Expand Down Expand Up @@ -293,7 +292,6 @@ type analyzeEncFunc func(byte) bool
// case2: could not use EncModeNumeric, but you can find all of them in character mapping, use EncModeAlphanumeric.
// case3: could not use EncModeAlphanumeric, but you can find all of them in ISO-8859-1 character set, use EncModeByte.
// case4: could not use EncModeByte, use EncModeJP, no more choice.
//
func analyzeEncodeModeFromRaw(raw []byte) encMode {
analyzeFnMapping := map[encMode]analyzeEncFunc{
EncModeNumeric: analyzeNum,
Expand Down
17 changes: 17 additions & 0 deletions encoder_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ type encodingOption struct {
// Version of target QR code.
Version int

// MinimumVersion specifies the minimum version of target QR code.
// If the automatically analyzed version is lower than this, this minimum will be used.
MinimumVersion int

// EncMode specifies which encMode to use
EncMode encMode

Expand Down Expand Up @@ -69,3 +73,16 @@ func WithVersion(version int) EncodeOption {
option.Version = version
})
}

// WithMinimumVersion sets the minimum version of target QR code.
// If the automatically analyzed version is lower than this minimum,
// the minimum version will be used instead.
func WithMinimumVersion(version int) EncodeOption {
return newFnEncodingOption(func(option *encodingOption) {
if version < 1 || version > _VERSION_COUNT {
return
}

option.MinimumVersion = version
})
}
2 changes: 1 addition & 1 deletion example/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/yeqown/go-qrcode v1.5.10
github.com/yeqown/go-qrcode/v2 v2.2.5
github.com/yeqown/go-qrcode/writer/file v0.0.0-20250211110803-2fa59f4d4375
github.com/yeqown/go-qrcode/writer/standard v1.2.4
github.com/yeqown/go-qrcode/writer/standard v1.3.0
github.com/yeqown/go-qrcode/writer/terminal v1.1.1
)

Expand Down
1 change: 1 addition & 0 deletions example/with-minimum-version/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.png
44 changes: 44 additions & 0 deletions example/with-minimum-version/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# QR Code with Minimum Version Example

This example demonstrates how to use the `WithMinimumVersion` option to ensure that a QR code has at least a specific version level.

## What is QR Code Version?

QR code versions range from 1 to 40, with higher versions supporting more data capacity and having larger dimensions:
- Version 1: 21x21 modules
- Version 9: 53x53 modules
- Version 40: 177x177 modules

The formula is: dimension = (version × 4) + 17

## Why Use Minimum Version?

Sometimes you want to ensure a QR code has a minimum size or capacity, even if the content would fit in a smaller version:

1. **Consistency**: Keep QR codes the same size across different content lengths
2. **Future-proofing**: Reserve capacity for potential content expansion
3. **Readability**: Larger QR codes are easier to scan from a distance
4. **Design requirements**: Match specific design or layout requirements

## Usage

```go
qrc, err := qrcode.NewWith("your-text-here",
qrcode.WithMinimumVersion(9),
qrcode.WithErrorCorrectionLevel(qrcode.ErrorCorrectionQuart),
)
```

## Running the Example

```bash
go run main.go
```

This will generate two QR codes:
1. `qrcode_minimum_version_9.png` - A QR code with minimum version 9 (53x53 modules)
2. `qrcode_auto_version.png` - The same content with automatic version selection (much smaller)

## Note

If the content naturally requires a version higher than the minimum, the higher version will be used. The minimum version only applies when the automatic version would be lower.
52 changes: 52 additions & 0 deletions example/with-minimum-version/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package main

import (
"fmt"

"github.com/yeqown/go-qrcode/v2"
"github.com/yeqown/go-qrcode/writer/standard"
)

func main() {
// Example 1: Generate a QR code with minimum version 9
// Even though the text "Hello" would fit in a smaller version,
// the QR code will be at least version 9
qrc, err := qrcode.NewWith("Hello",
qrcode.WithMinimumVersion(9),
qrcode.WithErrorCorrectionLevel(qrcode.ErrorCorrectionQuart),
)
if err != nil {
panic(fmt.Sprintf("could not generate QRCode: %v", err))
}

w, err := standard.New("./qrcode_minimum_version_9.png", standard.WithQRWidth(20))
if err != nil {
panic(fmt.Sprintf("could not create writer: %v", err))
}

if err = qrc.Save(w); err != nil {
panic(fmt.Sprintf("could not save QRCode: %v", err))
}

fmt.Printf("QR code generated with minimum version 9\n")
fmt.Printf("Dimension: %d x %d\n", qrc.Dimension(), qrc.Dimension())
fmt.Printf("Expected dimension for version 9: %d x %d\n", 9*4+17, 9*4+17)

// Example 2: Compare with automatic version selection
qrc2, err := qrcode.New("Hello")
if err != nil {
panic(fmt.Sprintf("could not generate QRCode: %v", err))
}

w2, err := standard.New("./qrcode_auto_version.png", standard.WithQRWidth(20))
if err != nil {
panic(fmt.Sprintf("could not create writer: %v", err))
}

if err = qrc2.Save(w2); err != nil {
panic(fmt.Sprintf("could not save QRCode: %v", err))
}

fmt.Printf("\nFor comparison, QR code with automatic version:\n")
fmt.Printf("Dimension: %d x %d (much smaller)\n", qrc2.Dimension(), qrc2.Dimension())
}
6 changes: 3 additions & 3 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ go 1.19
use (
.
./.issues
./cmd/qrcode
./cmd/wasm
./writer/compressed
./writer/file
./writer/standard
./writer/terminal
./writer/file
./cmd/qrcode
./cmd/wasm
example
)
65 changes: 26 additions & 39 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -1,70 +1,57 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/nsf/termbox-go v1.1.1/go.mod h1:T0cTdVuOwf7pHQNtfhnEbzHbcNyCEcVU4YPpouCbVxo=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/yeqown/go-qrcode v1.5.10/go.mod h1:0FVyJ3MV9fF5lfAgTr0INcy+3rupmJhjp0mL3Z9eYXk=
github.com/yeqown/go-qrcode/v2 v2.0.2/go.mod h1:Yy3DxXAv0XbWgniNafyB+6vpbZmUdCpvzeGy0h8ubXw=
github.com/yeqown/go-qrcode/v2 v2.2.2/go.mod h1:2Qsk2APUCPne0TsRo40DIkI5MYnbzYKCnKGEFWrxd24=
github.com/yeqown/go-qrcode/v2 v2.2.5/go.mod h1:uHpt9CM0V1HeXLz+Wg5MN50/sI/fQhfkZlOM+cOTHxw=
github.com/yeqown/go-qrcode/writer/compressed v1.0.1/go.mod h1:BJScsGUIKM+eg0CCLCcVaDTaclDM1IEXtq2r8qQnDKk=
github.com/yeqown/go-qrcode/writer/file v0.0.0-20250101101152-a2f3943410a2 h1:U3yuXYC0VwlSik09BQXbcx8wNAPHBQCVblOAlgknVcA=
github.com/yeqown/go-qrcode/writer/file v0.0.0-20250101101152-a2f3943410a2/go.mod h1:k5q4Y/A4VSAdrU5My6lt6KiT9F7kDy0yFpsni8h4lqI=
github.com/yeqown/go-qrcode/writer/file v0.0.0-20250211110803-2fa59f4d4375/go.mod h1:k5q4Y/A4VSAdrU5My6lt6KiT9F7kDy0yFpsni8h4lqI=
github.com/yeqown/go-qrcode/writer/standard v1.1.1/go.mod h1:GFrLTV4g3qxHdQesm5nKdNtbPa5cKDpFbmEib51Ofgs=
github.com/yeqown/go-qrcode/writer/standard v1.2.0/go.mod h1:ZelyDFiVymrauRjUn454iF7bjsabmB1vixkDA5kq2bw=
github.com/yeqown/go-qrcode/writer/standard v1.2.4/go.mod h1:H8nLSGYUWBpNyBPjDcJzAanMzYBBYMFtrU2lwoSRn+k=
github.com/yeqown/go-qrcode/writer/standard v1.3.0/go.mod h1:O4MbzsotGCvy8upYPCR91j81dr5XLT7heuljcNXW+oQ=
github.com/yeqown/go-qrcode/writer/terminal v1.1.0/go.mod h1:kh1Ru3RkCNKPYLcdmqh2VNNKPETUVDZScT/G9ZW1efs=
github.com/yeqown/go-qrcode/writer/terminal v1.1.1/go.mod h1:7Fn5MU6v2Eq1Mx/EOn2OMt2NmaWYSeM+Iu9w2SrY338=
github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/image v0.5.0 h1:5JMiNunQeQw++mMOz48/ISeNu3Iweh/JaZU8ZLqHRrI=
golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4=
golang.org/x/image v0.10.0/go.mod h1:jtrku+n79PfroUbvDdeUWMAI+heR786BofxrbiSF+J0=
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/image v0.24.0/go.mod h1:4b/ITuLfqYq1hqZcjofwctIhi7sZh2WaCjvsBNjjya8=
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0 h1:L4ZwwTvKW9gr0ZMS1yrHD9GZhIuVjOBBnaKH+SPQK0Q=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
1 change: 0 additions & 1 deletion mask_evaluation.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ func rule3(mat *Matrix) (score int) {
// 5. Subtract 50 from each of these multiples of five and take the absolute qrbool of the result.
// 6. Divide each of these by five. For example, 10/5 = 2 and 5/5 = 1.
// 7. Finally, take the smallest of the two numbers and multiply it by 10.
//
func rule4(mat *Matrix) int {
// prerequisites:
//
Expand Down
5 changes: 5 additions & 0 deletions qrcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ func (q *QRCode) calcVersion() (ver *version, err error) {
return nil, err
}
opt.Version = analyzed.Ver

// Apply minimum version constraint if set
if opt.MinimumVersion > 0 && opt.Version < opt.MinimumVersion {
opt.Version = opt.MinimumVersion
}
}

q.v = loadVersion(opt.Version, opt.EcLevel)
Expand Down
Loading
Loading