forked from indymedia/epicyon
Remove metadata using external tool
parent
d6955968a1
commit
f719918145
21
media.py
21
media.py
|
@ -20,21 +20,16 @@ from shutil import rmtree
|
||||||
from shutil import move
|
from shutil import move
|
||||||
|
|
||||||
def removeMetaData(imageFilename: str,outputFilename: str) -> None:
|
def removeMetaData(imageFilename: str,outputFilename: str) -> None:
|
||||||
"""TODO At present metadata removal results in garbled images
|
"""Attempts to do this with pure python didn't work well,
|
||||||
so this is a simple copy for now
|
so better to use a dedicated tool if one is installed
|
||||||
"""
|
"""
|
||||||
copyfile(imageFilename,outputFilename)
|
copyfile(imageFilename,outputFilename)
|
||||||
return
|
if os.path.isfile('/usr/bin/exiftool'):
|
||||||
#imageFile = open(imageFilename)
|
print('Removing metadata from '+outputFilename+' using exiftool')
|
||||||
#image = Image.open(imageFilename)
|
os.system('exiftool -all= '+outputFilename)
|
||||||
#if not image:
|
elif os.path.isfile('/usr/bin/mogrify'):
|
||||||
# return
|
print('Removing metadata from '+outputFilename+' using mogrify')
|
||||||
#data = list(image.getdata())
|
os.system('/usr/bin/mogrify -strip '+outputFilename)
|
||||||
#if not data:
|
|
||||||
# return
|
|
||||||
#imageWithoutExif = Image.new(image.mode, image.size)
|
|
||||||
#imageWithoutExif.putdata(data)
|
|
||||||
#imageWithoutExif.save(outputFilename)
|
|
||||||
|
|
||||||
def getImageHash(imageFilename: str) -> str:
|
def getImageHash(imageFilename: str) -> str:
|
||||||
return blurencode(numpy.array(Image.open(imageFilename).convert("RGB")))
|
return blurencode(numpy.array(Image.open(imageFilename).convert("RGB")))
|
||||||
|
|
Loading…
Reference in New Issue