Welcome to py-gs1-barcode-engine’s documentation!¶
A thin Python wrapper of https://github.com/gs1/gs1-barcode-engine.
Docs: https://gs1-barcode-engine-python-wrapper.readthedocs.io/en/latest/
Pypi: https://pypi.org/project/py-gs1-barcode-engine/
Source: https://bitbucket.org/stolmen/gs1-wrapper
- py_gs1_barcode_engine.generate_gs1_datamatrix(data: str, dm_rows: Optional[int] = None, dm_cols: Optional[int] = None, scaling: Optional[dict] = None, x_undercut: Optional[float] = None, y_undercut: Optional[float] = None) bytes ¶
Generate a GS1 datamatrix.
- Parameters:
data (str) – Data to encode in barcode.
dm_rows (int or None) – Define the number of rows in the data matrix. If None, then gs1_barcode_engine will choose an appropriate value. See gs1_encoder_getDmRows.
dm_cols (int or None) – Define the number of columns in the data matrix. If None, then gs1_barcode_engine will choose an appropriate value. See gs1_encoder_setDmColumns.
scaling (dict or None) –
Scaling parameters to define the size of the generated output. This can be one of two styles. See Image Scaling Models for more details.
- Pixel scaling
No regard for physical dimensions - define module width in units of pixels
Use if physical dimensions are not known or are not important
Pass a dictionary containing one key
pix_mult
with an int value which is the width of a module in units of pixels. e.g.{"pix_mult": 5}
.
- Device dot scaling,
Define resolution of target medium and target module dimensions in physical dimensions.
Use if resolution of the output medium and target physical size are important.
Pass a dictionary with keys
resolution
(float) andtarget_x_dim
(float), and optionally the keysmin_x_dim
(float) andmax_x_dim
(float). These quantities must be in the same unit of measurement e.g. DPI and inches, otherwise this function may yield unexpected results. e.g.{"resolution": 300, "target_x_dim": 0.1}
The library will attempt to meet these contraints and if these constraints are invalid, py_gs1_barcode_engine.Gs1GeneratorError will be raised.
x_undercut (float or None) – Compensate for horizontal print growth by shaving this number of pixels from both sides of each module. None is equivalent to 0. See gs1_encoder_setXundercut.
y_undercut (float or None) – Compensate for vertical print growth by shaving this number of pixels from both sides of each module. None is equivalent to 0. See gs1_encoder_setYundercut.
- Raises:
py_gs1_barcode_engine.Gs1GeneratorError – If the underlying library raises an exception.
- Returns:
BMP image as bytes
- Return type:
bytes