new CLI: brother_ql

This will slowly deprecate the other CLIs such as
* brother_ql_create
* brother_ql_print
* brother_ql_info
* brother_ql_analyze
* brother_ql_debug
This commit is contained in:
Philipp Klaus
2018-08-08 18:43:20 +02:00
parent 388eaae2d6
commit 160cea90d4
5 changed files with 358 additions and 164 deletions
+65 -109
View File
@@ -51,125 +51,81 @@ This package was mainly created for use with Python 3. The essential functionali
## Usage
The main user interface of this package are its command line tools.
You can also use its functionality from your own Python code (yet, there is no dedicated API documentation).
The following sections show how to use the most important CLI tools.
The main user interface of this package is the command line tool `brother_ql`.
### Create
The command line tool `brother_ql_create` is possibly the most important piece of software in this package.
It allows you to create a new instruction file in the label printers' raster language:
brother_ql_create --model QL-500 ./720x300_monochrome.png > 720x300_monochrome.bin
If you want to find out about its options, just call the tool with `--help`:
brother_ql_create --help
giving:
usage: brother_ql_create [-h] [--model MODEL] [--label-size LABEL_SIZE]
[--rotate {0,90,180,270}] [--threshold THRESHOLD]
[--dither] [--compress] [--red] [--600dpi] [--no-cut]
[--loglevel LOGLEVEL]
image [outfile]
Usage: brother_ql [OPTIONS] COMMAND [ARGS]...
positional arguments:
image The image file to create a label from.
outfile The file to write the instructions to. Defaults to
stdout.
Command line interface for the brother_ql Python package.
optional arguments:
-h, --help show this help message and exit
--model MODEL, -m MODEL
The printer model to use. Check available ones with
`brother_ql_info list-models`.
--label-size LABEL_SIZE, -s LABEL_SIZE
The label size (and kind) to use. Check available ones
with `brother_ql_info list-label-sizes`.
--rotate {0,90,180,270}, -r {0,90,180,270}
Rotate the image (counterclock-wise) by this amount of
degrees.
--threshold THRESHOLD, -t THRESHOLD
The threshold value (in percent) to discriminate
between black and white pixels.
--dither, -d Enable dithering when converting the image to b/w. If
set, --threshold is meaningless.
--compress, -c Enable compression (if available with the model).
Takes more time but results in smaller file size.
--red Create a label to be printed on black/red/white tape
(only with QL-8xx series on DK-22251 labels). You must
use this option when printing on black/red tape, even
when not printing red.
--600dpi Print with 600x300 dpi available on some models.
Provide your image as 600x600 dpi; perpendicular to
the feeding the image will be resized to 300dpi.
--no-cut Don't cut the tape after printing the label.
--loglevel LOGLEVEL Set to DEBUG for verbose debugging output to stderr.
Options:
-b, --backend [pyusb|network|linux_kernel]
-m, --model [QL-500|QL-550|QL-560|QL-570|QL-580N|QL-650TD|QL-700|QL-710W|QL-720NW|QL-800|QL-810W|QL-820NWB|QL-1050|QL-1060N]
-p, --printer PRINTER_IDENTIFIER
The identifier for the printer. This could
be a string like tcp://192.168.1.21:9100 for
a networked printer or
usb://0x04f9:0x2015/000M6Z401370 for a
printer connected via USB.
--debug
--help Show this message and exit.
Commands:
analyze interpret a binary file containing raster...
discover find connected label printers
info list available choices (for labels or models)
print Print a label
send send an instruction file to the printer
The image argument should be a PNG/GIF/JPEG image file.
Here is the output of `brother_ql_info list-label-sizes` listing the available options for `--label-size`:
There are some global options available such as --model and --printer.
They can also be provided by environment variables (`BROTHER_QL_MODEL` and `BROTHER_QL_PRINTER`).
Supported label sizes:
Name Printable px Description
12 106 (12 mm endless)
29 306 (29 mm endless)
38 413 (38 mm endless)
50 554 (50 mm endless)
54 590 (54 mm endless)
62 696 (62 mm endless)
102 1164 (102 mm endless)
17x54 165 x 566 (17 x 54 mm^2)
17x87 165 x 956 (17 x 87 mm^2)
23x23 202 x 202 (23 x 23 mm^2)
29x42 306 x 425 (29 x 42 mm^2)
29x90 306 x 991 (29 x 90 mm^2)
39x90 413 x 991 (38 x 90 mm^2)
39x48 425 x 495 (39 x 48 mm^2)
52x29 578 x 271 (52 x 29 mm^2)
62x29 696 x 271 (62 x 29 mm^2)
62x100 696 x 1109 (62 x 100 mm^2)
102x51 1164 x 526 (102 x 51 mm^2)
102x152 1164 x 1660 (102 x 152 mm^2)
d12 94 x 94 (12 mm diameter, round)
d24 236 x 236 (24 mm diameter, round)
d58 618 x 618 (58 mm diameter, round)
The global options are followed by a command such as `info` or `print`.
The most important command is the `print` command and here is its CLI signature:
**Pro Tip™**:
For the best results, use image files with the matching pixel dimensions. Die-cut labels have to be in the exact pixel dimensions stated above. For endless label rolls, you can provide image files with a pixel width as stated above. If you provide a file with different dimensions when creating an endless label file, it will be scaled to fit the width.
Usage: brother_ql print [OPTIONS] IMAGE [IMAGE] ...
Print a label of the provided IMAGE.
Options:
-l, --label [12|29|38|50|54|62|102|17x54|17x87|23x23|29x42|29x90|39x90|39x48|52x29|62x29|62x100|102x51|102x152|d12|d24|d58]
The label (size, type - die-cut or endless).
Run `brother_ql info list-labels` for a full
list including ideal pixel dimensions.
-r, --rotate [auto|0|90|180|270]
Rotate the image (counterclock-wise) by this
amount of degrees.
-t, --threshold FLOAT The threshold value (in percent) to
discriminate between black and white pixels.
-d, --dither Enable dithering when converting the image
to b/w. If set, --threshold is meaningless.
-c, --compress Enable compression (if available with the
model). Label creation can take slightly
longer but the resulting instruction size is
normally considerably smaller.
--red Create a label to be printed on
black/red/white tape (only with QL-8xx
series on DK-22251 labels). You must use
this option when printing on black/red tape,
even when not printing red.
--600dpi Print with 600x300 dpi available on some
models. Provide your image as 600x600 dpi;
perpendicular to the feeding the image will
be resized to 300dpi.
--lq Print with low quality (faster). Default is
high quality.
--no-cut / --cut Don't cut the tape after printing the label.
--help Show this message and exit.
### Print
So, printing an image file onto 62mm endless tape on a QL-710W label printer can be as easy as:
Once you have a Brother QL instruction file, you can send it to the printer like this:
export BROTHER_QL_PRINTER=tcp://192.168.1.21
export BROTHER_QL_MODEL=QL-710W
brother_ql print -l 62 my_image.png
cat my_label.bin > /dev/usb/lp1
### Legacy command line tools
Be sure to have permission to write to the device (usually adding yourself to the *lp* group is sufficient.
Or via network (if you have a LAN/WLAN enabled Brother QL):
nc 192.168.0.23 9100 < my_label.bin
You can also use the tool `brother_ql_print` (Py3 only) to send the instructions to your printer:
brother_ql_print 720x151_monochrome.bin /dev/usb/lp0
# or
brother_ql_print --backend network 720x151_monochrome.bin tcp://192.168.0.23:9100
# or (requires PyUSB: `pip install pyusb`)
brother_ql_print 720x151_monochrome.bin usb://0x04f9:0x2015
# or if you have multiple ones connected:
brother_ql_print 720x151_monochrome.bin usb://0x04f9:0x2015/000M6Z401370
# where 000M6Z401370 is the serial number (see lsusb output).
If your printer has problems printing the instructions file, it may blink its LED (green or red) depending on the model. This can have many reasons, eg.:
* The selected label doesn't match (make sure `--red` has been passed to `brother_ql_create` if you're using black/red labels).
* End of paper.
* Unsupported opcode (wrong `--model` when using `brother_ql_create`?)
## Debugging
More info on how to debug difficult situations is to be found in the [DEBUG doc](https://github.com/pklaus/brother_ql/blob/master/DEBUG.md).
For a long time, this project provided multiple command line tools, such as `brother_ql_create`, `brother_ql_print`, `brother_ql_analyze`, and more.
A documentation of their usage can be found in the [LEGACY](https://github.com/pklaus/brother_ql/blob/master/LEGACY.md).
## Links