Skip to content

Commit 57a0674

Browse files
committed
Adding verbose feature
1 parent 3f6db5b commit 57a0674

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

IMAGES & PHOTO SCRIPTS/Image-Inverter/inverter.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,24 @@ def main():
1414
""" The main function """
1515
check_input()
1616

17+
verbose_enabled = False
18+
if ("-v" in sys.argv) or ("--verbose" in sys.argv):
19+
verbose_enabled = True
20+
1721
i = 0
1822
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":
2125
i = i + 1
2226
continue
2327

2428
image_path_no_ext, extension = os.path.splitext(file)
2529

2630
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")
2835

2936
i = i + 1
3037

0 commit comments

Comments
 (0)