31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
import subprocess, os
|
|
from brother_ql.conversion import convert
|
|
from brother_ql.backends.helpers import send
|
|
from brother_ql.raster import BrotherQLRaster
|
|
|
|
class BrotherQlPrinter():
|
|
|
|
backend = 'pyusb'
|
|
|
|
def __init__(self, model='QL-800', printer_connection='usb://0x04f9:0x209b', label_format='12', red_label=False):
|
|
self.model = model
|
|
self.printer = printer_connection
|
|
self.label = label_format
|
|
self.red_label = red_label
|
|
|
|
def print_image(self, image, rotation='Auto', cut=True):
|
|
qlr = BrotherQLRaster(self.model)
|
|
qlr.exception_on_warning = True
|
|
instructions = convert(qlr=qlr,
|
|
images = [image],
|
|
label=self.label,
|
|
rotate = str(rotation),
|
|
threshold=70.0,
|
|
dither = False,
|
|
compress = False,
|
|
red = self.red_label,
|
|
dpi_600=False,
|
|
hq = True,
|
|
cut = cut
|
|
)
|
|
send(instructions=instructions, printer_identifier=self.printer, backend_identifier=self.backend, blocking=True) |