-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblankimage.py
68 lines (59 loc) · 1.4 KB
/
blankimage.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
import argparse
import PIL.Image
import sys
from voussoirkit import betterhelp
from voussoirkit import vlogging
log = vlogging.getLogger(__name__, 'blankimage')
def blankimage_argparse(args):
if args.width and args.height:
size = (args.width, args.height)
else:
size = (512, 512)
if args.color:
color = args.color
else:
color = (255, 255, 255, 255)
image = PIL.Image.new('RGBA', size, color=color)
for filename in args.names:
image.save(filename)
return 0
@vlogging.main_decorator
def main(argv):
parser = argparse.ArgumentParser(
description='''
Create a blank image file.
''',
)
parser.add_argument(
'names',
nargs='+',
help='''
One or more filenames. The same image will be saved to each.
''',
)
parser.add_argument(
'--width',
default=None,
type=int,
help='''
''',
)
parser.add_argument(
'--height',
default=None,
type=int,
help='''
''',
)
parser.add_argument(
'--color',
default=None,
type=str,
help='''
A hex color like #fff or #0a0a0a or #ff0000ff.
''',
)
parser.set_defaults(func=blankimage_argparse)
return betterhelp.go(parser, argv)
if __name__ == '__main__':
raise SystemExit(main(sys.argv[1:]))