Skip to content

Commit

Permalink
Merge pull request #24 from inventree/fix-rotation
Browse files Browse the repository at this point in the history
Fix rotation
  • Loading branch information
SchrodingersGat committed Aug 8, 2023
2 parents 3da0664 + 73cf9a5 commit c057ee7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion inventree_brother/brother_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ def print_label(self, **kwargs):
if label_specs.identifier == media_type:
media_specs = label_specs

rotation = int(self.get_setting('ROTATION'))

try:
# Resize image if media type is a die cut label (the brother_ql library only accepts images
# with a specific size in that case)
Expand All @@ -147,6 +149,17 @@ def print_label(self, **kwargs):
if media_specs.form_factor in [FormFactor.DIE_CUT, FormFactor.ROUND_DIE_CUT]:
# 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 @@ -169,7 +182,7 @@ def print_label(self, **kwargs):
'images': [printable_image],
'label': media_type,
'cut': self.get_setting('AUTO_CUT'),
'rotate': self.get_setting('ROTATION'),
'rotate': rotation,
'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.0"
BROTHER_PLUGIN_VERSION = "0.7.1"

0 comments on commit c057ee7

Please sign in to comment.