From df9862b86610a0726f659d3cff7418837e177ac5 Mon Sep 17 00:00:00 2001 From: GeekyKayaker Date: Mon, 22 Jul 2024 17:04:17 +0100 Subject: [PATCH] Add some options to CreateThumbnail to allow for some customisation over the format of the begin block for the image --- .../scripts/CreateThumbnail.py | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/plugins/PostProcessingPlugin/scripts/CreateThumbnail.py b/plugins/PostProcessingPlugin/scripts/CreateThumbnail.py index 7d6094ade31..8f0c74ceee5 100644 --- a/plugins/PostProcessingPlugin/scripts/CreateThumbnail.py +++ b/plugins/PostProcessingPlugin/scripts/CreateThumbnail.py @@ -35,16 +35,21 @@ def _encodeSnapshot(self, snapshot): def _convertSnapshotToGcode(self, encoded_snapshot, width, height, chunk_size=78): gcode = [] + use_thumbnail = self.getSettingValueByKey("use_thumbnail") + use_star = self.getSettingValueByKey("use_star") + encoded_snapshot_length = len(encoded_snapshot) + image_type = "thumbnail" if use_thumbnail else "png" + resolution_symbol = '*' if use_star else 'x' gcode.append(";") - gcode.append("; thumbnail begin {}x{} {}".format( - width, height, encoded_snapshot_length)) + gcode.append("; {} begin {}{}{} {}".format( + image_type, width, resolution_symbol, height, encoded_snapshot_length)) chunks = ["; {}".format(encoded_snapshot[i:i+chunk_size]) for i in range(0, len(encoded_snapshot), chunk_size)] gcode.extend(chunks) - gcode.append("; thumbnail end") + gcode.append("; {} end".format(image_type)) gcode.append(";") gcode.append("") @@ -79,6 +84,20 @@ def getSettingDataString(self): "minimum_value": "0", "minimum_value_warning": "12", "maximum_value_warning": "600" + }, + "use_thumbnail": + { + "label": "Thumbnail Begin/End", + "description": "Use Thumbnail Begin/End rather than PNG", + "type": "bool", + "default_value": true + }, + "use_star": + { + "label": "xxx*yyy", + "description": "Use '*' instead of 'x' for size of image", + "type": "bool", + "default_value": false } } }"""