Greg Wanger
Greg Wanger

Reputation: 41

Printing Label from Brother QL-800 label printer

I am trying to print a label from windows 10 using a python script and the brother_ql library. How do I create and print a label?

Using PIL I have created an image that I would like to have printed on a label. Now I want to create a label for my Brother QL-800 label printer.

from brother_ql import BrotherQLRaster, create_label
from brother_ql.backends import backend_factory, guess_backend
from brother_ql.devicedependent import models, label_type_specs, 
label_sizes
from PIL import Image

LABEL_SIZES = [(name, label_type_specs[name]['name']) for name in 
label_sizes]
model = [m for m in models]
printer_model = model[9]  #QL-800
label_type = LABEL_SIZES[12]  #('29x90', '29mm x 90mm die-cut')

im = Image.open('tempQR.png', 'r')
im = im.resize((306, 991))
qlr = BrotherQLRaster(printer_model)

label = create_label(qlr, im, label_size='29x90', threshold=70, cut=True, 
rotate=0)

Upvotes: 4

Views: 7251

Answers (1)

ReallyBigTeeth
ReallyBigTeeth

Reputation: 61

I know this is a year old question, but I haven't found any documentation posted anywhere on the internet, so here it is. I had a fun time figuring this out for myself.

Read the section "Backends" from here: http://brother-ql.net/readme.html and download and run the windows usb driver filter. If you haven't already, it's worth reading the whole page.

I have tested this code on Windows 10 and a Raspberry pi 4 running Raspbian.

from PIL import Image
from brother_ql.conversion import convert
from brother_ql.backends.helpers import send
from brother_ql.raster import BrotherQLRaster

im = Image.open('tempQR.png')
im.resize((306, 991)) 

backend = 'pyusb'    # 'pyusb', 'linux_kernal', 'network'
model = 'QL-800' # your printer model.
printer = 'usb://0x04f9:0x209b'    # Get these values from the Windows usb driver filter.  Linux/Raspberry Pi uses '/dev/usb/lp0'.

qlr = BrotherQLRaster(model)
qlr.exception_on_warning = True

instructions = convert(

        qlr=qlr, 
        images=[im],    #  Takes a list of file names or PIL objects.
        label='29x90', 
        rotate='90',    # 'Auto', '0', '90', '270'
        threshold=70.0,    # Black and white threshold in percent.
        dither=False, 
        compress=False, 
        red=False,    # Only True if using Red/Black 62 mm label tape.
        dpi_600=False, 
        hq=True,    # False for low quality.
        cut=True

)

send(instructions=instructions, printer_identifier=printer, backend_identifier=backend, blocking=True)

This is basically the "print_cmd" function from the brother_ql library file "cli.py"

Upvotes: 6

Related Questions