Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adjusting size of barcode image output

I am trying to adjust the size of a barcode output

import barcode
from barcode.writer import ImageWriter

bar_class = barcode.get_barcode_class('code128')
barcode = '1234567890'
writer=ImageWriter()
writer.set_options({module_width:2, module_height:2})
code128 = bar_class(barcode, writer)
code128.save('filename')

The error I am getting is:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'module_width' is not defined

I dont really understand how to use the documentation found here: https://pythonhosted.org/pyBarcode/writers/index.html

like image 589
Z.Chen Avatar asked Oct 29 '25 03:10

Z.Chen


1 Answers

I solved this problem by changing this line

code128.save('filename', {"module_width":0.35, "module_height":10, "font_size": 18, "text_distance": 1, "quiet_zone": 3})

without using another liabrary.

like image 101
A.Z. Soft Avatar answered Oct 31 '25 18:10

A.Z. Soft



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!