File tree 1 file changed +10
-3
lines changed
IMAGES & PHOTO SCRIPTS/Image-Inverter
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -14,17 +14,24 @@ def main():
14
14
""" The main function """
15
15
check_input ()
16
16
17
+ verbose_enabled = False
18
+ if ("-v" in sys .argv ) or ("--verbose" in sys .argv ):
19
+ verbose_enabled = True
20
+
17
21
i = 0
18
22
for file in sys .argv :
19
- # To ignore the first parameter -> the script call
20
- if i == 0 :
23
+ # To ignore the first parameter -> the script call + -v + --verbose
24
+ if i == 0 or sys . argv [ i ] == "-v" or sys . argv [ i ] == "--verbose" :
21
25
i = i + 1
22
26
continue
23
27
24
28
image_path_no_ext , extension = os .path .splitext (file )
25
29
26
30
with Image .open (file ) as image :
27
- ImageOps .invert (image ).save (image_path_no_ext + "_inverted" + extension )
31
+ new_path_with_ext = image_path_no_ext + "_inverted" + extension
32
+ ImageOps .invert (image ).save (new_path_with_ext )
33
+ if verbose_enabled :
34
+ print ("Successfully inverted " + file + "\n " + new_path_with_ext + " is generated.\n " )
28
35
29
36
i = i + 1
30
37
You can’t perform that action at this time.
0 commit comments