Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added QL-600 #113

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ In more details, the following is possible with this package:
The following printers are claimed to be supported (✓ means verified by the author or by contributors):

* 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 (✓), and QL-1060N (✓).
QL-720NW (✓), QL-800 (✓), QL-810W (✓), QL-820NWB (✓), QL-1050 (✓), QL-1060N (✓), and QL-600

The new QL-800 series can print labels with two colors (black and red) on DK-22251 labels.

Expand Down Expand Up @@ -64,12 +64,12 @@ On those systems, extending the path variable via `export PATH="${PATH}:~/.local
The main user interface of this package is the command line tool `brother_ql`.

Usage: brother_ql [OPTIONS] COMMAND [ARGS]...

Command line interface for the brother_ql Python package.

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]
-m, --model [QL-500|QL-550|QL-560|QL-570|QL-580N|QL-600|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
Expand All @@ -79,13 +79,14 @@ The main user interface of this package is the command line tool `brother_ql`.
--debug
--version Show the version and exit.
--help Show this message and exit.

Commands:
analyze interpret a binary file containing raster...
discover find connected label printers
info list available labels, models etc.
print Print a label
send send an instruction file to the printer
save generates an instruction file and saves it

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`).
Expand All @@ -94,9 +95,9 @@ 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:

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).
Expand Down Expand Up @@ -203,7 +204,7 @@ removed in a future release.
This software package was written by Philipp Klaus based on Brother's documentation
of its raster language and based on additinal reverse engineering efforts.

* Philipp Klaus
* Philipp Klaus
<[email protected]>

Many more have contributed by raising issues, helping to solve them,
Expand Down
27 changes: 27 additions & 0 deletions brother_ql/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,33 @@ def print_cmd(ctx, *args, **kwargs):
instructions = convert(qlr=qlr, **kwargs)
send(instructions=instructions, printer_identifier=printer, backend_identifier=backend, blocking=True)

@cli.command('save', short_help='Generates a file and saves it')
@click.argument('output', type=click.File('wb'), metavar='FILE [FILE]')
@click.argument('images', nargs=-1, type=click.File('rb'), metavar='IMAGE [IMAGE] ...')
@click.option('-l', '--label', type=click.Choice(label_sizes), envvar='BROTHER_QL_LABEL', help='The label (size, type - die-cut or endless). Run `brother_ql info labels` for a full list including ideal pixel dimensions.')
@click.option('-r', '--rotate', type=click.Choice(('auto', '0', '90', '180', '270')), default='auto', help='Rotate the image (counterclock-wise) by this amount of degrees.')
@click.option('-t', '--threshold', type=float, default=70.0, help='The threshold value (in percent) to discriminate between black and white pixels.')
@click.option('-d', '--dither', is_flag=True, help='Enable dithering when converting the image to b/w. If set, --threshold is meaningless.')
@click.option('-c', '--compress', is_flag=True, help='Enable compression (if available with the model). Label creation can take slightly longer but the resulting instruction size is normally considerably smaller.')
@click.option('--red', is_flag=True, help='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.')
@click.option('--600dpi', 'dpi_600', is_flag=True, help='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.')
@click.option('--lq', is_flag=True, help='Print with low quality (faster). Default is high quality.')
@click.option('--no-cut', is_flag=True, help="Don't cut the tape after printing the label.")
@click.pass_context
def save_cmd(ctx, *args, **kwargs):
""" Print a label of the provided IMAGE. """
model = ctx.meta.get('MODEL')
from brother_ql.conversion import convert
from brother_ql.backends.helpers import send
from brother_ql.raster import BrotherQLRaster
qlr = BrotherQLRaster(model)
qlr.exception_on_warning = True
kwargs['cut'] = not kwargs['no_cut']
del kwargs['no_cut']
instructions = convert(qlr=qlr, **kwargs)
with open('output.bin', mode='wb') as f:
f.write(instructions)

@cli.command(name='analyze', help='interpret a binary file containing raster instructions for the Brother QL-Series printers')
@click.argument('instructions', type=click.File('rb'))
@click.option('-f', '--filename-format', help="Filename format string. Default is: label{counter:04d}.png.")
Expand Down
1 change: 1 addition & 0 deletions brother_ql/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def name(self):
Model('QL-1060N', (295, 35433), number_bytes_per_row=162, additional_offset_r=44),
Model('PT-P750W', (31, 14172), number_bytes_per_row=16),
Model('PT-P900W', (57, 28346), number_bytes_per_row=70),
Model('QL-600', (150, 11811), compression=False, mode_setting=True),
]

class ModelsManager(ElementsManager):
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
LDESC = ''

setup(name='brother_ql',
version = '0.9.dev0',
version = '0.9.dev1',
description = 'Python package to talk to Brother QL label printers',
long_description = LDESC,
author = 'Philipp Klaus',
Expand Down Expand Up @@ -51,7 +51,7 @@
#'brother_ql_analyse': ["matplotlib",],
#'brother_ql_create' : ["matplotlib",],
},
keywords = 'Brother QL-500 QL-550 QL-560 QL-570 QL-700 QL-710W QL-720NW QL-800 QL-810W QL-820NWB QL-1050 QL-1060N',
keywords = 'Brother QL-500 QL-550 QL-560 QL-570 QL-600 QL-700 QL-710W QL-720NW QL-800 QL-810W QL-820NWB QL-1050 QL-1060N',
classifiers = [
'Development Status :: 4 - Beta',
'Operating System :: OS Independent',
Expand Down