Skip to content

Commit

Permalink
Fix webcam transform 2 (#86)
Browse files Browse the repository at this point in the history
* Add apply transform

* Bump version to 2.1.3
  • Loading branch information
crysxd authored Jul 6, 2024
1 parent 5f374b8 commit 953fe3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions octoprint_octoapp/webcamsnapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def OnApiCommand(self, command, data):
try:
with self.WebcamSnapshotCacheLock:
webcamIndex = data.get("webcamIndex", 0)
applyTransform = data.get("applyTransform", True) is True
webcamSettings = self._getWebcamSettingsItem(webcamIndex)
cache = self.WebcamSnapshotCache.get(webcamIndex)

Expand All @@ -49,13 +50,13 @@ def OnApiCommand(self, command, data):
size = min(max(image.width, image.height), int(data.get("size", 720)))
image.thumbnail([size, size])

if (webcamSettings.Rotation != 0):
image = image.rotate(webcamSettings.Rotation, expand=True)
if (applyTransform and webcamSettings.Rotation != 0):
image = image.rotate(-webcamSettings.Rotation, expand=True)

if (webcamSettings.FlipV):
if (applyTransform and webcamSettings.FlipV):
image = image.transpose(Image.FLIP_TOP_BOTTOM)

if (webcamSettings.FlipH):
if (applyTransform and webcamSettings.FlipH):
image = image.transpose(Image.FLIP_LEFT_RIGHT)

imageBytes = BytesIO()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
# Note that this is also parsed by the moonraker module to pull the version, so the string and format must remain the same!
plugin_version = "2.1.2"
plugin_version = "2.1.3"

# 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 953fe3a

Please sign in to comment.