Command-line interface¶
Installing pyStrich exposes a pystrich console script with a subcommand
per format and PNG / SVG / EPS / ASCII / terminal / DXF output.
$ pystrich qrcode --text "https://en.wikipedia.org/wiki/Jasper,_Missouri" -o jasper.svg
$ pystrich code128 --text "Dalton" -o dalton.png
$ pystrich ean13 --text "5050070007664" -o ean13.png
$ echo "DLB 573" | pystrich code39 -o code39.png
$ pystrich datamatrix --text "Rausschmeißer" # terminal preview
The last example produces:
█ █▄█ █▄▀ █ █▄▀ ▀▄
█▀▄ ▄█▀ ▄█▄ █▀▄ █▄
█▄▄▀▀▄▄▀ ▀ ▀▄█ █▄
█▀█ ▄▀▄█ ▄█▄█▀ ▄▄
█ █▀▄▀▀█▀▄ ██▀▀▄ ▄
██▄ ▀█ ▀▄▀█▀█▀▀█▄
█▀▄▄▀ ▀▄▀ ▀ █▀▄█▄▄
██▄ ▄ █▀▄█▀███▄█▄
█▄▄██▄▄██▄▄██▄█▄▄▄
Reference¶
Generate 1D/2D barcodes (Code 39, Code 128, EAN-13, Data Matrix, QR Code). Pass input via –text or stdin.
usage: pystrich [-h] [--version] FORMAT ...
Positional Arguments¶
- FORMAT
Possible choices: code39, code128, ean13, datamatrix, qrcode
Named Arguments¶
- --version
show program’s version number and exit
Sub-commands¶
code39¶
Code 39 (1D)
pystrich code39 [-h] [--text TEXT] [-o OUTPUT] [-t {auto,png,svg,eps}]
[--bar-width BAR_WIDTH] [--height HEIGHT] [--full-ascii]
[--show-label | --no-show-label]
Named Arguments¶
- --text
text to encode (default: read from stdin)
- -o, --output
output path; ‘-’ or omitted writes to stdout
- -t, --type
Possible choices: auto, png, svg, eps
output format; ‘auto’ resolves from -o filename or output context
Default:
'auto'- --bar-width
width of the narrowest bar (default: 3)
Default:
3- --height
image height in pixels
- --full-ascii
enable full-ASCII Code 39 encoding
Default:
False- --show-label, --no-show-label
render the human-readable label below the bars
code128¶
Code 128 (1D)
pystrich code128 [-h] [--text TEXT] [-o OUTPUT] [-t {auto,png,svg,eps}]
[--bar-width BAR_WIDTH] [--height HEIGHT]
[--show-label | --no-show-label]
Named Arguments¶
- --text
text to encode (default: read from stdin)
- -o, --output
output path; ‘-’ or omitted writes to stdout
- -t, --type
Possible choices: auto, png, svg, eps
output format; ‘auto’ resolves from -o filename or output context
Default:
'auto'- --bar-width
width of the narrowest bar (default: 3)
Default:
3- --height
image height in pixels
- --show-label, --no-show-label
render the human-readable label below the bars
ean13¶
EAN-13 (1D, 12 or 13 digits)
pystrich ean13 [-h] [--text TEXT] [-o OUTPUT] [-t {auto,png,svg,eps}]
[--bar-width BAR_WIDTH] [--height HEIGHT]
Named Arguments¶
- --text
12 or 13 digits (default: read from stdin)
- -o, --output
output path; ‘-’ or omitted writes to stdout
- -t, --type
Possible choices: auto, png, svg, eps
output format; ‘auto’ resolves from -o filename or output context
Default:
'auto'- --bar-width
width of the narrowest bar (default: 3)
Default:
3- --height
image height in pixels
datamatrix¶
Data Matrix (2D)
pystrich datamatrix [-h] [--text TEXT] [-o OUTPUT]
[-t {auto,png,svg,eps,ascii,terminal,dxf}]
[--cell-size CELL_SIZE] [--inverse | --no-inverse]
[--mark-shape {square,circular,horizontal-runs}]
[--dxf-units {in,ft,mi,mm,cm,m,unspecified}]
[--quiet-zone QUIET_ZONE]
[--encoding {auto,ascii,iso-8859-1,utf-8}]
[--substitute-with-fnc1 CHAR]
Named Arguments¶
- --text
text to encode (default: read from stdin)
- -o, --output
output path; ‘-’ or omitted writes to stdout
- -t, --type
Possible choices: auto, png, svg, eps, ascii, terminal, dxf
output format; ‘auto’ resolves from -o filename or output context
Default:
'auto'- --cell-size
side length of one module (default: 5 for raster/SVG/EPS, 1.0 for DXF)
- --inverse, --no-inverse
invert (light cells filled instead of dark); applies to svg/eps/dxf
- --mark-shape
Possible choices: square, circular, horizontal-runs
how matched cells are drawn in vector output
- --dxf-units
Possible choices: in, ft, mi, mm, cm, m, unspecified
DXF units (default: mm); ‘unspecified’ writes $INSUNITS=0
- --quiet-zone
quiet-zone width in cells (default: 2)
Default:
2- --encoding
Possible choices: auto, ascii, iso-8859-1, utf-8
DataMatrix charset (default: auto picks the narrowest that fits)
Default:
'auto'- --substitute-with-fnc1
replace each occurrence of CHAR in –text with an FNC1 codeword
qrcode¶
QR Code (2D)
pystrich qrcode [-h] [--text TEXT] [-o OUTPUT]
[-t {auto,png,svg,eps,ascii,terminal,dxf}]
[--cell-size CELL_SIZE] [--inverse | --no-inverse]
[--mark-shape {square,circular,horizontal-runs}]
[--dxf-units {in,ft,mi,mm,cm,m,unspecified}] [--ecl {L,M,Q,H}]
Named Arguments¶
- --text
text to encode (default: read from stdin)
- -o, --output
output path; ‘-’ or omitted writes to stdout
- -t, --type
Possible choices: auto, png, svg, eps, ascii, terminal, dxf
output format; ‘auto’ resolves from -o filename or output context
Default:
'auto'- --cell-size
side length of one module (default: 5 for raster/SVG/EPS, 1.0 for DXF)
- --inverse, --no-inverse
invert (light cells filled instead of dark); applies to svg/eps/dxf
- --mark-shape
Possible choices: square, circular, horizontal-runs
how matched cells are drawn in vector output
- --dxf-units
Possible choices: in, ft, mi, mm, cm, m, unspecified
DXF units (default: mm); ‘unspecified’ writes $INSUNITS=0
- --ecl
Possible choices: L, M, Q, H
error-correction level (default: M)
Format auto-detection¶
The output format is auto-detected from the -o filename
(.png, .svg, .eps, .dxf); without -o it defaults to
terminal for 2D formats when stdout is a TTY. Piped or redirected
output without an explicit -t is rejected, to avoid dumping binary
into the next tool by accident.
GS1 Data Matrix from the shell¶
GS1 Data Matrix uses ASCII with FNC1 markers separating application
identifiers and their values. --substitute-with-fnc1 lets you build
that input from a shell-friendly string:
$ pystrich datamatrix \
--text "|0105050070007664" \
--substitute-with-fnc1 "|" \
-o gs1.png
See Data Matrix for the full encoding discussion.
Limitations¶
The CLI doesn’t expose every Python-API knob. Reach for the Python API for
1D label fonts, custom borders, EAN-13’s first_digit_y_offset, or the
deprecated DataMatrix compat encoding.
API¶
Command-line interface for pyStrich.
Run pystrich --help for usage. Each subcommand corresponds to a barcode
format and uses the matching Encoder class.
- class Format[source]¶
Bases:
ABCAbstract barcode format. Leaf subclasses are registered in FORMATS.
- class Code39[source]¶
Bases:
OneDFormat
- class Code128[source]¶
Bases:
OneDFormat
- class EAN13[source]¶
Bases:
OneDFormat
- class DataMatrix[source]¶
Bases:
TwoDFormat
- class QRCode[source]¶
Bases:
TwoDFormat