-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrokedrawer.py
31 lines (21 loc) · 937 Bytes
/
strokedrawer.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
#!/usr/bin/env python
from PIL import Image, ImageDraw
from argparse import ArgumentParser
import sys
#This script opens up a temp file and an image file existing in its
#directory and uses ImageDraw to add line segments from the temp
#file to the image file
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("--destination", action = "store", help = "Where to save the file", required = True)
parser.add_argument("--name", action = "store", help = "Under what name to save the file", required = True)
o = parser.parse_args()
#open the image file
pic = Image.new('1',(5000,5000),color='white')
#set up a drawing context
draw = ImageDraw.Draw(pic)
for lines in sys.stdin.readlines():
lines = lines.strip().split()
lines = [ float(x)/10 for x in lines ]
draw.line(lines,width=3)
pic.save(o.destination+"/"+o.name+".png","PNG")