-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.py
41 lines (35 loc) · 878 Bytes
/
generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import barcode
from barcode.writer import ImageWriter
optionsSvg = {
'module_height': 10,
# 'quiet_zone': 10,
'font_size':8,
'text_distance': 3
}
optionsPng = {
'module_height': 10,
# 'quiet_zone': 10,
'font_size':15,
'text_distance': 1
}
imgWriter = ImageWriter()
options = optionsPng
# options = optionsSvg
# imgWriter = None #using with svg
imgWriter.set_options(options)
EAN = barcode.get('code128', options=options,)
def run(saveDir, text):
print(text)
ean = EAN(text,writer=imgWriter)
fullname = ean.save(saveDir + text, options=options)
def main():
filename = 'input.txt'
with open(filename, 'r') as f:
lines = f.read().splitlines()
for line in lines:
run('./output/', line)
def test():
line = '23800143401321'
fullname = run('./output-test/',line,)
main()
# test()