center text on die-cut labels; improved annotation in web iface

This commit is contained in:
Philipp Klaus 2016-12-17 22:58:18 +01:00
parent c8b3c501f0
commit b59f981cec
2 changed files with 6 additions and 1 deletions

View File

@ -106,7 +106,11 @@ def create_label_im(text, **kwargs):
im = Image.new('L', (kwargs['width'], height), 'white') im = Image.new('L', (kwargs['width'], height), 'white')
draw = ImageDraw.Draw(im) draw = ImageDraw.Draw(im)
textsize = draw.multiline_textsize(text, font=im_font) textsize = draw.multiline_textsize(text, font=im_font)
vertical_offset = 0 #(height - textsize[1])//2 if 'x' in kwargs['label_size']:
# die-cut labels
vertical_offset = (height - textsize[1])//2
else:
vertical_offset = 0
horizontal_offset = max((kwargs['width'] - textsize[0])//2, 0) horizontal_offset = max((kwargs['width'] - textsize[0])//2, 0)
if 'ttf' in kwargs['font_path']: vertical_offset -= 10 if 'ttf' in kwargs['font_path']: vertical_offset -= 10
offset = horizontal_offset, vertical_offset offset = horizontal_offset, vertical_offset

View File

@ -6,6 +6,7 @@
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
<fieldset class="form-group"> <fieldset class="form-group">
<label for="labelSize">Label Size:</label>
<select class="form-control" id="labelSize" onChange="preview()"> <select class="form-control" id="labelSize" onChange="preview()">
{% for label_size in label_sizes %}<option value="{{label_size[0]}}">{{label_size[1]}}</option>{% endfor %} {% for label_size in label_sizes %}<option value="{{label_size[0]}}">{{label_size[1]}}</option>{% endfor %}
</select> </select>