Skip to content

Karimerto/zplconvert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZPLConvert

ZPLConvert provides a simple tool for converting images to ZPL compatible strings.

Installation

pip install zplconvert

Requirements

ZPLConvert needs one of the following:

Example use

Included is a simple main program that can be used from the command line to convert images.

zplconvert zebra_logo.png

will read zebra_logo.png, convert it to black and white, then to compressed ZPL Ascii and print the result to stdout.

If you want more control, you can use the following flags:

Flag Description
--no-compress Do not compress the result image (useful for debugging).
--position x,y Add a positional header to the output.
--threshold value Set black pixel threshold (0-255, default 128).
--dither Dither the result instead of hard limit for black pixels.
--label Add header and footer needed for a complete ZPL label. This allows the result to be sent directly to a printer (e.g. with curl).
--output filename Write result to file instead of stdout.

The same converter can be used directly from Python as well

from zplconvert import ZPLConvert
convert = ZPLConvert("zebra_logo.png")
convert.set_compress_hex(True)
result = convert.convert()

See the code for other options that can be set on the converter.

Also included is a helper utility for converting ZPL images back to PNG (or any other image format supported by PIL).

zplparse --output logo.png zebra_logo.grf

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Karimerto/zplconvert.

License

This source is released under the standard MIT License

Zebra logo

Zebra Logo

The Zebra Logo was copied from Zebra Design.