Skip to content

Commit c057ee7

Browse files
Merge pull request #24 from inventree/fix-rotation
Fix rotation
2 parents 3da0664 + 73cf9a5 commit c057ee7

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

inventree_brother/brother_plugin.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ def print_label(self, **kwargs):
139139
if label_specs.identifier == media_type:
140140
media_specs = label_specs
141141

142+
rotation = int(self.get_setting('ROTATION'))
143+
142144
try:
143145
# Resize image if media type is a die cut label (the brother_ql library only accepts images
144146
# with a specific size in that case)
@@ -147,6 +149,17 @@ def print_label(self, **kwargs):
147149
if media_specs.form_factor in [FormFactor.DIE_CUT, FormFactor.ROUND_DIE_CUT]:
148150
# Scale image to fit the entire printable area and pad with whitespace (while preserving aspect ratio)
149151
printable_image = ImageOps.pad(label_image, media_specs.dots_printable, color="white")
152+
153+
if rotation == 90:
154+
# Rotate image 90 degrees
155+
printable_image = printable_image.rotate(90, expand=True)
156+
elif rotation == 180:
157+
# Rotate image 180 degrees
158+
printable_image = printable_image.rotate(180, expand=True)
159+
elif rotation == 270:
160+
# Rotate image 270 degrees
161+
printable_image = printable_image.rotate(270, expand=True)
162+
150163
else:
151164
# Just leave image as-is
152165
printable_image = label_image
@@ -169,7 +182,7 @@ def print_label(self, **kwargs):
169182
'images': [printable_image],
170183
'label': media_type,
171184
'cut': self.get_setting('AUTO_CUT'),
172-
'rotate': self.get_setting('ROTATION'),
185+
'rotate': rotation,
173186
'compress': self.get_setting('COMPRESSION'),
174187
'hq': self.get_setting('HQ'),
175188
'red': red,

inventree_brother/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Version information for the plugin"""
22

3-
BROTHER_PLUGIN_VERSION = "0.7.0"
3+
BROTHER_PLUGIN_VERSION = "0.7.1"

0 commit comments

Comments
 (0)