-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcmds.py
89 lines (85 loc) · 2.53 KB
/
cmds.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
84
85
86
87
88
89
import argparse
def parsecmds():
"""
Parses the command line arguments and returns the parsed arguments
"""
cmd_parser = argparse.ArgumentParser(
prog="REMOVEBG",
description="Remove Background of Image, With A Lot More Features",
)
cmd_parser.add_argument(
"--setapi",
type=str,
help="add new or edit stored api key (use with '--img' flag",
required=False,
default="empty",
)
cmd_parser.add_argument(
"--img", type=str, help="Path of Image or Image URL to Remove Bg", required=True
)
cmd_parser.add_argument(
"--filename",
type=str,
help="Output Name Of Imagefile | Default:'bg_removed.png'",
required=False,
default="bg_removed.png",
)
cmd_parser.add_argument(
"--size",
type=str,
help="size of the output image ('auto' = highest available resolution, 'preview'",
required=False,
default="auto",
)
cmd_parser.add_argument(
"--type",
type=str,
help="foreground object ('auto' = autodetect, 'person', 'product', 'car')",
required=False,
default="auto",
)
cmd_parser.add_argument(
"--format",
type=str,
required=False,
help="Image Type of Output JPG, PNG, ZIP | PNG for Transparent !",
default="png",
)
cmd_parser.add_argument(
"--ch",
type=str,
help="request the finalized image ('rgba') or an alpha mask ('alpha')",
required=False,
)
cmd_parser.add_argument(
"--crop",
type=bool,
help="Whether to crop off all empty regions | Takes Boolean(true/false)(default: false).",
required=False,
default="false",
)
cmd_parser.add_argument(
"--bgcolor",
type=str,
help="Adds a solid color background.HEX color(e.g.81d4fa) or name(e.g. green).RGBA hex codes supported",
required=False,
default="",
)
cmd_parser.add_argument(
"--bgimgurl",
type=bool,
help="Adds a background image from a direct image url",
required=False,
)
cmd_parser.add_argument(
"--bgimgfile",
type=bool,
help="Adds a background image from a file name/path",
required=False,
)
arguments = cmd_parser.parse_args()
if not arguments.setapi == "empty":
with open(".apikey.txt", "w") as f:
f.write(arguments.setapi)
print("[bold green] API Key Stored Successfully")
return arguments