Skip to content

Commit 62b1949

Browse files
committed
Removed try/except statment, and corrected the conversion part of the code
1 parent 6d50f03 commit 62b1949

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ def main():
1717
i = i + 1
1818
continue
1919

20-
file_name = os.path.splitext(file)
21-
try:
22-
with Image.open(file) as image:
23-
ImageOps.invert(image).save(file_name + "_inverted", "JPEG")
24-
except:
25-
print("Couldn't convert " + file_name + "successfully!")
20+
image_path, extension = os.path.splitext(file)
21+
22+
with Image.open(file) as image:
23+
ImageOps.invert(image).save(image_path + "_inverted" + extension, "JPEG")
24+
2625
i = i + 1
2726

2827
if __name__ == '__main__':

0 commit comments

Comments
 (0)