Skip to content

Commit 20641b8

Browse files
committed
Added error handling to the conversion code
1 parent f05aada commit 20641b8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ def main():
1818
continue
1919

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

2528
if __name__ == '__main__':

0 commit comments

Comments
 (0)