Update label generation, websocket listen mode
This commit is contained in:
@@ -269,10 +269,10 @@ def qr_image(data, width=600):
|
||||
png_image_io = "belden-logo-superhires.png"
|
||||
png_image_pillow = Image.open(png_image_io)
|
||||
png_width, png_height = png_image_pillow.size
|
||||
png_image_pillow = png_image_pillow.resize((int(width*5.2), int(width*5.2/png_width*png_height)))
|
||||
png_image_pillow = png_image_pillow.resize((int(width*4), int(width*4/png_width*png_height)))
|
||||
png_width, png_height = png_image_pillow.size
|
||||
# paste belden logo first because it has a big border that would cover stuff up
|
||||
img.paste(png_image_pillow, (int(width*5-png_width/2), int(width*4.25 - png_height/2)))
|
||||
img.paste(png_image_pillow, (int(width*5-png_width/2), int(width*3.25 - png_height/2)))
|
||||
|
||||
# draw circle border
|
||||
#draw.arc(((width - width/5, width - width/5), (width*9 + width/5, width*9 + width/5)),0,360,fill='blue', width = int(width/8))
|
||||
@@ -289,7 +289,7 @@ def qr_image(data, width=600):
|
||||
text_width = font.getlength(partnum[2:])
|
||||
|
||||
txtx = (int(width * 10) - text_width) / 2
|
||||
txty = (int(width * 10)) / 2
|
||||
txty = (int(width * 7.5)) / 2
|
||||
# draw part number text
|
||||
draw.text((txtx,txty),partnum[2:], "black", font)
|
||||
|
||||
@@ -298,10 +298,11 @@ def qr_image(data, width=600):
|
||||
qrcode = segno.make('HTTPS://BLDN.APP/' + partnum,micro=False,boost_error=False,error="L",mask=3)
|
||||
out = io.BytesIO()
|
||||
qrx, _ = qrcode.symbol_size(1,0)
|
||||
qrcode.save(out, scale=width*2/qrx, kind="PNG", border=0)
|
||||
qrcode.save(out, scale=width*3/qrx, kind="PNG", border=0)
|
||||
qrimg = Image.open(out)
|
||||
img.paste(qrimg, box=(int(width*4),int(width*5.75)))
|
||||
|
||||
img.paste(qrimg, box=(int(width*3.5),int(width*4.5)))
|
||||
img = img.crop((width+int(width / 1.4)-int(width/8),width+int(width / 1.4)-int(width/8),img.size[0] - (width+int(width / 1.4)-int(width/8)), img.size[1] - (width+int(width / 1.4)-int(width/8)) ))
|
||||
img = img.resize((1200, 1200), Image.LANCZOS) # 1200 dpi
|
||||
|
||||
return img
|
||||
|
||||
|
||||
Reference in New Issue
Block a user