-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
84 lines (63 loc) · 2.34 KB
/
main.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from image import *
from docopt import docopt
usage = '''
Image Manipulation
Usage: main.py (-l <input_file> -p <position>) (-o <output_file>) [(-t <text>)]
main.py (-i <input_file> -T <text>) (-o <output_file>)
main.py (--logo <input_file> --position <position>) --output <output_file>
main.py (-h | --help)
Examples:
Add a logo of sponsor on the input image
main.py -l logos/sponsor.png -p bcl -o parth
main.py --logo logos/sponsor.png --position bcl --output parth
Add logo with text
main.py -l logos/sponsor.png -p bcl -o parth -t GCS2020
Positions - Watermark:
tl Top Left Corner
b Below Watermark Image
tc Top Center
r On Right Of Watermark Image
tr Top Right
cl Center Left
c Center
cr Center Right
bl Bottom Left
bc Bottom Center
br Bottom Right
bcl Bottom Center Left
Positions - Watermark With Text:
tl Top Left Corner
tc Top Center
tr Top Right
cl Center Left
c Center
cr Center Right
bl Bottom Left
bc Bottom Center
br Bottom Right
'''
def main():
global OUTPUT
args = docopt(usage, version='Image Manipulation v1')
if args['-l' and '-p' and '-o' ]:
logo = str(args['<input_file>'])
position = str(args['<position>'])
output_name = str(args['<output_file>'])
OUTPUT = OUTPUT+output_name+".png"
if args['-t']:
text = str(args['<text>'])
watermark(INPUT, OUTPUT, logo, position, text, color=COLOR, text_size=TEXT_SIZE, text_position=TEXT_ALIGN_WATERMARK)
else:
watermark(INPUT, OUTPUT, logo, position)
elif args['-i' and '-T' and '-o']:
image = str(args['<input_file>'])
text = str(args['<text>'])
output_name = str(args['<output_file>'])
OUTPUT = OUTPUT+output_name+".png"
if args['-p']:
position = str(args['<position>'])
watermark_with_text(image, OUTPUT, text, position, color=COLOR, text_size=TEXT_SIZE)
else:
watermark_with_text(image, OUTPUT, text, text_position=TEXT_POSITION, color=COLOR, text_size=TEXT_SIZE)
if __name__ == '__main__':
main()