Skip to content

Commit

Permalink
0.1.1
Browse files Browse the repository at this point in the history
- updated extraction logic for improved performance
- added github action workflow
- added stalebot
  • Loading branch information
jneilliii committed May 16, 2020
1 parent c6bae83 commit d56a152
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ exemptLabels:
- enhancement
- bug
- solved
- documentation
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# PrusaSlicer Thumbnails

![GitHub Downloads](https://badgen.net/github/assets-dl/jneilliii/OctoPrint-PrusaSlicerThumbnails/)

This plugin will extract the embedded thumbnails from PrusaSlicer gcode files where the printer's profile ini file has the thumbnail option configured. This is default behavior for the Prusa Mini printer profile.

The thumbnail image extracted will always be the last resolution provided in the thumbnail setting. So for example the Prusa Mini setting is `thumbnails = 16x16,220x124` so the thumbnail that will be extracted will be 220x124 pixels as seen in the screenshots below. Check the Configuration section below for additional details.
Expand Down
16 changes: 14 additions & 2 deletions octoprint_prusaslicerthumbnails/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,20 @@ def _extract_thumbnail(self, gcode_filename, thumbnail_filename):
import re
import base64
regex = r"(?:^; thumbnail begin \d+x\d+ \d+)(?:\n|\r\n?)((?:.+(?:\n|\r\n?))+)(?:^; thumbnail end)"
lineNum = 0
collectedString = ""
with open(gcode_filename,"rb") as gcode_file:
test_str = gcode_file.read().decode('utf-8')
for line in gcode_file:
lineNum += 1
gcode = octoprint.util.comm.gcode_command_for_cmd(line)
extrusionMatch = octoprint.util.comm.regexes_parameters["floatE"].search(line)
if gcode == "G1" and extrusionMatch:
self._logger.debug("Line %d: Detected first extrusion. Read complete.", lineNum)
break
if line.startswith(";") or line.startswith("\n"):
collectedString += line
self._logger.debug(collectedString)
test_str = collectedString
test_str = test_str.replace(octoprint.util.to_native_str('\r\n'),octoprint.util.to_native_str('\n'))
matches = re.findall(regex, test_str, re.MULTILINE)
if len(matches) > 0:
Expand Down Expand Up @@ -148,7 +160,7 @@ def get_update_information(self):
current=self._plugin_version,

# update method: pip
pip="https://github.com/jneilliii/OctoPrint-PrusaSlicerThumbnails/archive/{target_version}.zip"
pip="https://github.com/jneilliii/OctoPrint-PrusaSlicerThumbnails/releases/latest/download/{target_version}.zip"
)
)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "PrusaSlicer Thumbnails"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "0.1.0"
plugin_version = "0.1.1"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit d56a152

Please sign in to comment.