Command-line interface¶
Installing pyStrich exposes a pystrich console script with a subcommand
per format and PNG / SVG / EPS / ASCII / terminal / DXF output.
Tip
To try the CLI without installing pyStrich into an environment, run it through pipx or uvx:
$ pipx run pystrich datamatrix --text "Rausschmeißer"
$ uvx pystrich datamatrix --text "Rausschmeißer"
$ 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, Interleaved 2 of 5, ITF-14, Data Matrix, QR Code, PDF417, Aztec Code). Pass input via --text or stdin.
pystrich [-h] [--version] FORMAT ...
pystrich options¶
pystrich code39¶
Code 39 (1D)
pystrich code39 [-h] [--text TEXT] [-o OUTPUT] [-t {auto,png,svg,eps}] [--dark-hex HEX]
[--light-hex HEX] [--bar-width BAR_WIDTH] [--height HEIGHT] [--full-ascii]
[--show-label | --no-show-label]
pystrich code39 options¶
--textTEXT- text to encode (default: read from stdin)-oOUTPUT,--outputOUTPUT- output path;'-'or omitted writes to stdout-tOUTPUT_TYPE,--typeOUTPUT_TYPE- output format;'auto'resolves from -o filename or output context--dark-hexHEX- dark (foreground) colour as 3, 6 or 8 hex digits; png/svg/eps only--light-hexHEX- light (background) colour as 3, 6 or 8 hex digits; png/svg/eps only--bar-widthBAR_WIDTH- width of the narrowest bar (default: 3)--heightHEIGHT- image height in pixels--full-ascii- enable full-ASCII Code 39 encoding--show-label,--no-show-label- render the human-readable label below the bars
pystrich code128¶
Code 128 (1D)
pystrich code128 [-h] [--text TEXT] [-o OUTPUT] [-t {auto,png,svg,eps}] [--dark-hex HEX]
[--light-hex HEX] [--bar-width BAR_WIDTH] [--height HEIGHT]
[--show-label | --no-show-label]
pystrich code128 options¶
--textTEXT- text to encode (default: read from stdin)-oOUTPUT,--outputOUTPUT- output path;'-'or omitted writes to stdout-tOUTPUT_TYPE,--typeOUTPUT_TYPE- output format;'auto'resolves from -o filename or output context--dark-hexHEX- dark (foreground) colour as 3, 6 or 8 hex digits; png/svg/eps only--light-hexHEX- light (background) colour as 3, 6 or 8 hex digits; png/svg/eps only--bar-widthBAR_WIDTH- width of the narrowest bar (default: 3)--heightHEIGHT- image height in pixels--show-label,--no-show-label- render the human-readable label below the bars
pystrich ean13¶
EAN-13 (1D, 12 or 13 digits)
pystrich ean13 [-h] [--text TEXT] [-o OUTPUT] [-t {auto,png,svg,eps}] [--dark-hex HEX]
[--light-hex HEX] [--bar-width BAR_WIDTH] [--height HEIGHT]
pystrich ean13 options¶
--textTEXT- 12 or 13 digits (default: read from stdin)-oOUTPUT,--outputOUTPUT- output path;'-'or omitted writes to stdout-tOUTPUT_TYPE,--typeOUTPUT_TYPE- output format;'auto'resolves from -o filename or output context--dark-hexHEX- dark (foreground) colour as 3, 6 or 8 hex digits; png/svg/eps only--light-hexHEX- light (background) colour as 3, 6 or 8 hex digits; png/svg/eps only--bar-widthBAR_WIDTH- width of the narrowest bar (default: 3)--heightHEIGHT- image height in pixels
pystrich itf¶
Interleaved 2 of 5 (1D, an even number of digits)
pystrich itf [-h] [--text TEXT] [-o OUTPUT] [-t {auto,png,svg,eps}] [--dark-hex HEX]
[--light-hex HEX] [--bar-width BAR_WIDTH] [--height HEIGHT]
[--bearer-width BEARER_WIDTH]
pystrich itf options¶
--textTEXT- an even number of digits (default: read from stdin)-oOUTPUT,--outputOUTPUT- output path;'-'or omitted writes to stdout-tOUTPUT_TYPE,--typeOUTPUT_TYPE- output format;'auto'resolves from -o filename or output context--dark-hexHEX- dark (foreground) colour as 3, 6 or 8 hex digits; png/svg/eps only--light-hexHEX- light (background) colour as 3, 6 or 8 hex digits; png/svg/eps only--bar-widthBAR_WIDTH- width of the narrowest bar (default: 3)--heightHEIGHT- image height in pixels--bearer-widthBEARER_WIDTH- thickness of a bearer bar’s rules, in narrow-bar widths (default: none)
pystrich itf14¶
ITF-14 (1D, 13 or 14 digits, with bearer bar)
pystrich itf14 [-h] [--text TEXT] [-o OUTPUT] [-t {auto,png,svg,eps}] [--dark-hex HEX]
[--light-hex HEX] [--bar-width BAR_WIDTH] [--height HEIGHT]
[--bearer-width BEARER_WIDTH]
pystrich itf14 options¶
--textTEXT- 13 or 14 digits (default: read from stdin)-oOUTPUT,--outputOUTPUT- output path;'-'or omitted writes to stdout-tOUTPUT_TYPE,--typeOUTPUT_TYPE- output format;'auto'resolves from -o filename or output context--dark-hexHEX- dark (foreground) colour as 3, 6 or 8 hex digits; png/svg/eps only--light-hexHEX- light (background) colour as 3, 6 or 8 hex digits; png/svg/eps only--bar-widthBAR_WIDTH- width of the narrowest bar (default: 3)--heightHEIGHT- image height in pixels--bearer-widthBEARER_WIDTH- thickness of the bearer bar’s rules, in narrow-bar widths (default: 4)
pystrich datamatrix¶
Data Matrix (2D)
pystrich datamatrix [-h] [--text TEXT] [-o OUTPUT] [-t {auto,png,svg,eps,ascii,terminal,dxf}]
[--dark-hex HEX] [--light-hex HEX] [--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]
[--symbol-shape {square,rectangular,auto}]
pystrich datamatrix options¶
--textTEXT- text to encode (default: read from stdin)-oOUTPUT,--outputOUTPUT- output path;'-'or omitted writes to stdout-tOUTPUT_TYPE,--typeOUTPUT_TYPE- output format;'auto'resolves from -o filename or output context--dark-hexHEX- dark (foreground) colour as 3, 6 or 8 hex digits; png/svg/eps only--light-hexHEX- light (background) colour as 3, 6 or 8 hex digits; png/svg/eps only--cell-sizeCELL_SIZE- side length of one module; must be a whole number for png/svg/eps (default: 5), decimals are supported for dxf (default: 1.0)--inverse,--no-inverse- invert (light cells filled instead of dark); applies to svg/eps/dxf--mark-shapeMARK_SHAPE- how matched cells are drawn in vector output--dxf-unitsDXF_UNITS- DXF units (default: mm);'unspecified'writes $INSUNITS=0--quiet-zoneQUIET_ZONE- quiet-zone width in cells (default: 2)--encodingENCODING- DataMatrix charset (default: auto picks the narrowest that fits)--substitute-with-fnc1CHAR- replace each occurrence of CHAR in --text with an FNC1 codeword--symbol-shapeSYMBOL_SHAPE- Data Matrix shape (default: square)
pystrich qrcode¶
QR Code (2D)
pystrich qrcode [-h] [--text TEXT] [-o OUTPUT] [-t {auto,png,svg,eps,ascii,terminal,dxf}]
[--dark-hex HEX] [--light-hex HEX] [--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}]
pystrich qrcode options¶
--textTEXT- text to encode (default: read from stdin)-oOUTPUT,--outputOUTPUT- output path;'-'or omitted writes to stdout-tOUTPUT_TYPE,--typeOUTPUT_TYPE- output format;'auto'resolves from -o filename or output context--dark-hexHEX- dark (foreground) colour as 3, 6 or 8 hex digits; png/svg/eps only--light-hexHEX- light (background) colour as 3, 6 or 8 hex digits; png/svg/eps only--cell-sizeCELL_SIZE- side length of one module; must be a whole number for png/svg/eps (default: 5), decimals are supported for dxf (default: 1.0)--inverse,--no-inverse- invert (light cells filled instead of dark); applies to svg/eps/dxf--mark-shapeMARK_SHAPE- how matched cells are drawn in vector output--dxf-unitsDXF_UNITS- DXF units (default: mm);'unspecified'writes $INSUNITS=0--eclECL- error-correction level (default: M)
pystrich pdf417¶
PDF417 (stacked 2D)
pystrich pdf417 [-h] [--text TEXT] [-o OUTPUT] [-t {auto,png,svg,eps,ascii,terminal,dxf}]
[--dark-hex HEX] [--light-hex HEX] [--cell-size CELL_SIZE]
[--inverse | --no-inverse] [--mark-shape {square,circular,horizontal-runs}]
[--dxf-units {in,ft,mi,mm,cm,m,unspecified}] [--ecl {0,1,2,3,4,5,6,7,8}]
[--columns N] [--row-height ROW_HEIGHT] [--quiet-zone QUIET_ZONE]
pystrich pdf417 options¶
--textTEXT- text to encode (default: read from stdin)-oOUTPUT,--outputOUTPUT- output path;'-'or omitted writes to stdout-tOUTPUT_TYPE,--typeOUTPUT_TYPE- output format;'auto'resolves from -o filename or output context--dark-hexHEX- dark (foreground) colour as 3, 6 or 8 hex digits; png/svg/eps only--light-hexHEX- light (background) colour as 3, 6 or 8 hex digits; png/svg/eps only--cell-sizeCELL_SIZE- side length of one module; must be a whole number for png/svg/eps (default: 5), decimals are supported for dxf (default: 1.0)--inverse,--no-inverse- invert (light cells filled instead of dark); applies to svg/eps/dxf--mark-shapeMARK_SHAPE- how matched cells are drawn in vector output--dxf-unitsDXF_UNITS- DXF units (default: mm);'unspecified'writes $INSUNITS=0--eclECL- error-correction level 0-8 (default: chosen from data length)--columnsN- data columns 1-30 (default: minimal-area layout)--row-heightROW_HEIGHT- module-rows per codeword row (default: 3)--quiet-zoneQUIET_ZONE- quiet-zone width in modules (default: 2)
pystrich aztec¶
Aztec Code (2D)
pystrich aztec [-h] [--text TEXT] [-o OUTPUT] [-t {auto,png,svg,eps,ascii,terminal,dxf}]
[--dark-hex HEX] [--light-hex HEX] [--cell-size CELL_SIZE]
[--inverse | --no-inverse] [--mark-shape {square,circular,horizontal-runs}]
[--dxf-units {in,ft,mi,mm,cm,m,unspecified}] [--ecc PCT]
[--symbol-kind {auto,compact,full}] [--layers LAYERS]
[--quiet-zone QUIET_ZONE]
pystrich aztec options¶
--textTEXT- text to encode (default: read from stdin)-oOUTPUT,--outputOUTPUT- output path;'-'or omitted writes to stdout-tOUTPUT_TYPE,--typeOUTPUT_TYPE- output format;'auto'resolves from -o filename or output context--dark-hexHEX- dark (foreground) colour as 3, 6 or 8 hex digits; png/svg/eps only--light-hexHEX- light (background) colour as 3, 6 or 8 hex digits; png/svg/eps only--cell-sizeCELL_SIZE- side length of one module; must be a whole number for png/svg/eps (default: 5), decimals are supported for dxf (default: 1.0)--inverse,--no-inverse- invert (light cells filled instead of dark); applies to svg/eps/dxf--mark-shapeMARK_SHAPE- how matched cells are drawn in vector output--dxf-unitsDXF_UNITS- DXF units (default: mm);'unspecified'writes $INSUNITS=0--eccPCT- error-correction percentage 5..95 (default: 23)--symbol-kindSYMBOL_KIND- symbol kind (default: auto picks the smallest that fits)--layersLAYERS- data layer count; requires --symbol-kind compact or full--quiet-zoneQUIET_ZONE- quiet-zone width in modules (default: 2)
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.