forked from indymedia/epicyon
Handle failure to open image
parent
65227e7c59
commit
a21b7fd958
6
media.py
6
media.py
|
@ -19,10 +19,14 @@ from shutil import copyfile
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
from shutil import move
|
from shutil import move
|
||||||
|
|
||||||
def removeMetaData(imageFilename: str,outputFilename: str):
|
def removeMetaData(imageFilename: str,outputFilename: str) -> None:
|
||||||
imageFile = open(imageFilename)
|
imageFile = open(imageFilename)
|
||||||
image = Image.open(imageFilename)
|
image = Image.open(imageFilename)
|
||||||
|
if not image:
|
||||||
|
return
|
||||||
data = list(image.getdata())
|
data = list(image.getdata())
|
||||||
|
if not data:
|
||||||
|
return
|
||||||
imageWithoutExif = Image.new(image.mode, image.size)
|
imageWithoutExif = Image.new(image.mode, image.size)
|
||||||
imageWithoutExif.putdata(data)
|
imageWithoutExif.putdata(data)
|
||||||
imageWithoutExif.save(outputFilename)
|
imageWithoutExif.save(outputFilename)
|
||||||
|
|
Loading…
Reference in New Issue