Read saved QR images
Pass an image file path (PNG, JPEG, WebP or GIF) to scanner.Scan() and receive decoded QR text, raw bytes and score.
pkg.go.dev
Zero cgo
Uses qrscan
MIT
Drive the native qrscan binary from Go’s standard library with context cancellation and zero C compilation.
Pass an image file path (PNG, JPEG, WebP or GIF) to scanner.Scan() and receive decoded QR text, raw bytes and score.
Builds cleanly with CGO_ENABLED=0. Invokes the installed qrscan binary directly without a shell so filenames stay safe.
Check report.Found(), Detections, Score, Complete and report.JSON (unchanged engine output) with typed Go error handling.
Install the Go module and the qrscan CLI, then decode an image file with a Go context.
Requires Go 1.24 or later and the Go module on pkg.go.dev. Install the matching QR Code Scanner CLI binary separately via Homebrew, Scoop, Cargo, Debian/RPM, AUR, AppImage, GitHub Releases or container image.
The Go module holds no decoder of its own and never downloads qrscan automatically. Keeping both on the same release line passes the startup version check.
go get github.com/qrcode-ai-com/qrcode-barcode-scanner-go@v0.12.2
CGO_ENABLED=0 works out of the box because the adapter contains zero C code.
Pass an explicit binary path to qrscan.New("/path/to/qrscan") if qrscan is not on PATH.
Create a scanner with qrscan.New(""), call scanner.Scan with a context, profile and budget, and keep detections whose Symbology is qr_code. Canceling ctx stops the qrscan subprocess cleanly.
package main
import (
"context"
"fmt"
qrscan "github.com/qrcode-ai-com/qrcode-barcode-scanner-go"
)
func readQRImage(ctx context.Context, path string) ([]string, error) {
scanner := qrscan.New("")
report, err := scanner.Scan(ctx, path, qrscan.Full, qrscan.ProfileBudget)
if err != nil {
return nil, err
}
if !report.Complete {
return nil, fmt.Errorf("scan budget cut before completion")
}
var urls []string
for _, d := range report.Detections {
if d.Symbology == "qr_code" {
urls = append(urls, d.Text)
}
}
return urls, nil
}
Choose qrscan.Frame (decode only, nil Score), qrscan.Fast (reduced scoring) or qrscan.Full (full QR quality assessment).
Pass qrscan.Unbounded instead of qrscan.ProfileBudget when you want reproducible scans independent of host CPU load.
For a QR image encoding https://qrcode-ai.com/, readQRImage returns []string{"https://qrcode-ai.com/"}. Use report.JSON when you need the complete, unmodified engine JSON including geometry, payloads and trace.
No code found is a normal result: report.Found() is false and err is nil. Branch on qrscan.ErrBinaryNotFound (with errors.Is), *qrscan.UnsupportedVersionError, *qrscan.ScanError (EngineCode such as QRS-001) or the context error.
One process per scan. Each Scan() call executes qrscan directly from an argument list with no shell, so filenames containing spaces, quotes or leading dashes are never interpreted. This fits request handlers and batch jobs rather than tight loops over thousands of frames.
File input and why not WASM. Pass PNG, JPEG, WebP or GIF file paths (write in-memory uploads to a temp file first). Running the engine via native qrscan avoids the roughly twentyfold slowdown observed in earlier wazero WebAssembly experiments.
Untrusted payloads and license. Treat decoded text as untrusted data and never open URLs automatically. Project-authored adapter source is MIT; see the Go adapter README and Go module repository.
Official package documentation, ScanReport specification and licensing references.
cgo, qrscan prerequisite, contexts, budgets, errors, offline use and licensing.
It is QR Code AI’s open-source MIT Go module (github.com/qrcode-ai-com/qrcode-barcode-scanner-go) that drives a separately installed qrscan binary using only the Go standard library and returns the ScanReport unchanged.
No. It requires Go 1.24 or later, depends only on the standard library and compiles cleanly with CGO_ENABLED=0. You only need the native qrscan binary installed on the host or inside your container image.
An earlier experiment running the engine in Go via wazero produced identical reports but took roughly twenty times longer on photo-sized images. Driving native qrscan preserves full native speed with zero cgo complexity.
Scan() takes a file path (PNG, JPEG, WebP or GIF), so write in-memory bytes to a temporary file first. Because each scan starts one qrscan process, it suits web requests and batch jobs; for tight in-process loops, use the Rust, Node.js, Python or .NET bindings.
When no code is present, report.Found() is false and err is nil. If report.Complete is false, the budget cut the scan short and an empty result is not final; retry with qrscan.Unbounded. Errors return ErrBinaryNotFound, *UnsupportedVersionError, *ScanError (with EngineCode) or ctx.Err().
Yes. The adapter invokes qrscan from an explicit argument slice without a shell, so spaces, quotes, leading dashes and shell metacharacters in file paths are never interpreted.
No. The adapter writes nothing, fetches nothing and never visits decoded URLs. Everything runs locally on your machine or container without a QR Code AI account or API key.
Yes. Current releases of the Go adapter and qrscan engine are MIT-licensed for commercial and proprietary use while keeping copyright and license notices (see LICENSING.md). SDK use is separate from QR Code AI’s paid creation plans and seven-day Premium trial.