Handle failure to open image

main2
Bob Mottram 2019-10-26 12:56:41 +01:00
parent 65227e7c59
commit a21b7fd958
1 changed files with 5 additions and 1 deletions

View File

@ -19,10 +19,14 @@ from shutil import copyfile
from shutil import rmtree
from shutil import move
def removeMetaData(imageFilename: str,outputFilename: str):
def removeMetaData(imageFilename: str,outputFilename: str) -> None:
imageFile = open(imageFilename)
image = Image.open(imageFilename)
if not image:
return
data = list(image.getdata())
if not data:
return
imageWithoutExif = Image.new(image.mode, image.size)
imageWithoutExif.putdata(data)
imageWithoutExif.save(outputFilename)