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

Add some options to CreateThumbnail to allow for some customisation o… #19419

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
25 changes: 22 additions & 3 deletions plugins/PostProcessingPlugin/scripts/CreateThumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("")

Expand Down Expand Up @@ -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
}
}
}"""
Expand Down
Loading