Skip to content

Commit

Permalink
Merge pull request #27 from inventree/fix-rotation
Browse files Browse the repository at this point in the history
Simplify rotation
  • Loading branch information
SchrodingersGat committed Aug 22, 2023
2 parents c057ee7 + 9f14bf8 commit 6ffcc6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
18 changes: 6 additions & 12 deletions inventree_brother/brother_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ def print_label(self, **kwargs):
if label_specs.identifier == media_type:
media_specs = label_specs

rotation = int(self.get_setting('ROTATION'))
rotation = int(self.get_setting('ROTATION')) + 90
rotation = rotation % 360

if rotation in [90, 180, 270]:
label_image = label_image.rotate(rotation, expand=True)

try:
# Resize image if media type is a die cut label (the brother_ql library only accepts images
Expand All @@ -150,16 +154,6 @@ def print_label(self, **kwargs):
# Scale image to fit the entire printable area and pad with whitespace (while preserving aspect ratio)
printable_image = ImageOps.pad(label_image, media_specs.dots_printable, color="white")

if rotation == 90:
# Rotate image 90 degrees
printable_image = printable_image.rotate(90, expand=True)
elif rotation == 180:
# Rotate image 180 degrees
printable_image = printable_image.rotate(180, expand=True)
elif rotation == 270:
# Rotate image 270 degrees
printable_image = printable_image.rotate(270, expand=True)

else:
# Just leave image as-is
printable_image = label_image
Expand All @@ -182,7 +176,7 @@ def print_label(self, **kwargs):
'images': [printable_image],
'label': media_type,
'cut': self.get_setting('AUTO_CUT'),
'rotate': rotation,
'rotate': 0,
'compress': self.get_setting('COMPRESSION'),
'hq': self.get_setting('HQ'),
'red': red,
Expand Down
2 changes: 1 addition & 1 deletion inventree_brother/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Version information for the plugin"""

BROTHER_PLUGIN_VERSION = "0.7.1"
BROTHER_PLUGIN_VERSION = "0.7.2"

0 comments on commit 6ffcc6d

Please sign in to comment.