Pular para o conteúdo principal

raygeo.barcode

QR Code, Code 128 and EAN-13, encoded and rendered by raygeo

QR Code, Code 128 and EAN-13, encoded and rendered by raygeo Barcode and QR code generation.

Encodes text as QR Code, Code 128 or EAN-13 modules, and renders those modules to millimetre-space geometry with optional human-readable text, quiet-zone border and inverted variant.

The symbology modules expose their own encode function; the top-level encode dispatches by Symbology. geometry.to_geometry turns the encoded modules into closed outlines suitable for filling or contouring.

Encoded​

An encoded symbol.

guards​

guards: list[int]

The columns covered by EAN-13 guard bars.

height​

height: int

The symbol height in modules.

modules​

modules: list[list[bool]]

The module matrix, row-major, True for dark modules.

symbology​

symbology: Symbology

The symbology that produced this symbol.

text​

text: str

The human-readable text; EAN-13 includes the check digit.

width​

width: int

The symbol width in modules.

QrErrorCorrection​

A QR Code error-correction level.

Values:

  • H — High, roughly 30% recovery.
  • L — Low, roughly 7% recovery.
  • M — Medium, roughly 15% recovery.
  • Q — Quartile, roughly 25% recovery.

name​

name: str

value​

value: str

The stable serialization value ("L", "M", "Q", "H").

from_value()​

from_value(value: str) -> QrErrorCorrection

Parses a serialization value produced by value.

ParameterTypeDescription
valuestr
ReturnsQrErrorCorrection

Symbology​

A barcode symbology.

Values:

  • CODE128 — Code 128.
  • EAN13 — EAN-13.
  • QR — QR Code.

name​

name: str

value​

value: str

The stable serialization value ("qr", "code128", "ean13").

from_value()​

from_value(value: str) -> Symbology

Parses a serialization value produced by value.

ParameterTypeDescription
valuestr
ReturnsSymbology

Functions​

encode()​

encode(
text: str,
symbology: Symbology = Symbology.QR,
error_correction: QrErrorCorrection = QrErrorCorrection.M,
) -> Encoded

Encodes text in the requested symbology.

error_correction is used by QR only.

ParameterTypeDescription
textstr
symbologySymbology = Symbology.QR
error_correctionQrErrorCorrection = QrErrorCorrection.M
ReturnsEncoded

encode() dispatches to the symbology module and returns modules

encode() dispatches to the symbology module and returns modules

min_quiet_zone()​

min_quiet_zone(symbology: Symbology) -> int

The minimum quiet zone for a symbology, in modules.

ParameterTypeDescription
symbologySymbology
Returnsint

Inverted symbols with the minimum quiet zone per symbology

Inverted symbols with the minimum quiet zone per symbology