Commit 05bac429 authored by Jérome Perrin's avatar Jérome Perrin

base: make python3 barcode look similar to python2 barcodes

The library for python3 has differents, try to adjust it a bit.
parent e8f7082c
Pipeline #34327 failed with stage
in 0 seconds
...@@ -38,10 +38,21 @@ def generateBarcodeImage(self, barcode_type, data, REQUEST=None): ...@@ -38,10 +38,21 @@ def generateBarcodeImage(self, barcode_type, data, REQUEST=None):
barcode.codex.Code128( barcode.codex.Code128(
data, writer=NoTextImageWriter() data, writer=NoTextImageWriter()
).render( ).render(
# we also set a font_size of 0, so that the bounding box of the writer_options={
# image does not include white space for the text. # we also set a font_size of 0, so that the bounding box of the
writer_options={'font_size': 0} # image does not include white space for the text.
).save(fp, format='png') 'font_size': 0,
# We set some default sizes to have similar appearance as what we had
# with hubarcode on python2:
# bar width is 3
'module_width': REQUEST.get('module_width', 0.3),
# Quiet zone is 10 bar widths on each side
'quiet_zone': REQUEST.get('quiet_zone', 3.0),
# Height was calculated so that the total height was total width / 3,
# but here we dont' know the total width, we make an approximation with the
# length of the data
'module_height': REQUEST.get('module_height', len(data) * 1.1),
}).save(fp, format='png')
output = fp.getvalue() output = fp.getvalue()
else: else:
from hubarcode.code128 import Code128Encoder from hubarcode.code128 import Code128Encoder
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment