qr

package module
v0.0.0-...-f29915b Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

README

qr

QR code generation library with Sixel terminal output support.

Usage

package main

import (
	"os"

	"github.com/sshwap/qr"
)

func main() {
	q, _ := qr.New("https://example.com", qr.SizeMedium, qr.High)
	q.Sixel(os.Stdout)
}

Options

Recovery Levels: Low, Medium, High, Highest

Sizes: SizeSmall (128), SizeMedium (256), SizeLarge (512), SizeXLarge (1024)

Methods: Image(), Sixel(w), PNG(), ImageWithSize(n), SixelWithSize(w, n), PNGWithSize(n)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QR

type QR struct {
	// contains filtered or unexported fields
}

QR represents a generated QR code.

func New

func New(content string, size Size, level RecoveryLevel) (*QR, error)

New creates a new QR code with the given content, size, and recovery level.

func (*QR) Image

func (q *QR) Image() image.Image

Image returns the QR code as an image.Image.

func (*QR) ImageWithSize

func (q *QR) ImageWithSize(size int) image.Image

ImageWithSize returns the QR code as an image.Image with a custom size.

func (*QR) PNG

func (q *QR) PNG() ([]byte, error)

PNG returns the QR code as PNG bytes.

func (*QR) PNGWithSize

func (q *QR) PNGWithSize(size int) ([]byte, error)

PNGWithSize returns the QR code as PNG bytes with a custom size.

func (*QR) Sixel

func (q *QR) Sixel(w io.Writer) error

Sixel encodes the QR code as Sixel graphics to the given writer.

func (*QR) SixelWithSize

func (q *QR) SixelWithSize(w io.Writer, size int) error

SixelWithSize encodes the QR code as Sixel graphics with a custom size.

type RecoveryLevel

type RecoveryLevel int

RecoveryLevel represents the error correction level for QR codes.

const (
	Low     RecoveryLevel = iota // 7% recovery
	Medium                       // 15% recovery
	High                         // 25% recovery
	Highest                      // 30% recovery
)

type Size

type Size int

Size represents predefined QR code sizes in pixels.

const (
	SizeSmall  Size = 128
	SizeMedium Size = 256
	SizeLarge  Size = 512
	SizeXLarge Size = 1024
)

Jump to

Keyboard shortcuts

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