Add new printing options, change image conversion for Brother QL
printers
This commit is contained in:
1 parent
d254fa0d32
commit
72e6e93337
6 files changed
+80
-24
No files matched your search
+17
-4
@@ -460,22 +460,35 @@ class BrotherPrinter(Printer):
|
||||
"""Print text after converting it to an image"""
|
||||
self._print_img(text_to_image(msg))
|
||||
|
||||
def _print_img(self, data):
|
||||
def _print_img(self, data, process=False):
|
||||
"""
|
||||
Print a raster image via a Brother QL printer
|
||||
"""
|
||||
self.ready = False
|
||||
|
||||
if process:
|
||||
try:
|
||||
self.app.logger.debug("Proccessing the image")
|
||||
processed_path = _process_image(self, data)
|
||||
except RuntimeError as e:
|
||||
self.app.logger.error(
|
||||
"Error while processing the image, aborting print : %s", str(e)
|
||||
)
|
||||
raise e
|
||||
else:
|
||||
processed_path = data
|
||||
self.app.logger.warning("Not proccessing the image")
|
||||
try:
|
||||
selected_backend = guess_backend(self.printer_info.identifier)
|
||||
BACKEND_CLASS = backend_factory(selected_backend)['backend_class']
|
||||
BACKEND_STRING_DESCR = self.printer_info.identifier
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
self.app.logger.error("Couldn't guess the backend to use from the printer string descriptor")
|
||||
|
||||
try:
|
||||
im = Image.open(data)
|
||||
im = Image.open(processed_path)
|
||||
qlr = BrotherQLRaster(self.printer_info.model)
|
||||
create_label(qlr, im, self.printer_info.label_type, threshold=70, cut=False, rotate=0)
|
||||
create_label(qlr, im, self.printer_info.label_type, cut=False, dither=True)
|
||||
|
||||
# noinspection PyCallingNonCallable
|
||||
be = BACKEND_CLASS(BACKEND_STRING_DESCR)
|
||||
|
||||
Reference in new issue
Block a user