From b181d3891111693f3f25fc6fc6085fb5cb2d0f50 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 24 Jul 2019 14:14:23 +0100 Subject: [PATCH] Remove metadata from attached images --- media.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/media.py b/media.py index 5ea2ca5a..9afa5b69 100644 --- a/media.py +++ b/media.py @@ -19,6 +19,14 @@ from shutil import copyfile from shutil import rmtree from shutil import move +def removeMetaData(imageFilename: str,outputFilename: str): + imageFile = open(imageFilename) + image = Image.open(imageFilename) + data = list(image.getdata()) + imageWithoutExif = Image.new(image.mode, image.size) + imageWithoutExif.putdata(data) + imageWithoutExif.save(outputFilename) + def getImageHash(imageFilename: str) -> str: return blurencode(numpy.array(Image.open(imageFilename).convert("RGB"))) @@ -80,7 +88,8 @@ def attachImage(baseDir: str,httpPrefix: str,domain: str,port: int, \ postJson['attachment']=[attachmentJson] if baseDir: - copyfile(imageFilename,mediaFilename) + removeMetaData(imageFilename,mediaFilename) + #copyfile(imageFilename,mediaFilename) return postJson