Skip to content

Instantly share code, notes, and snippets.

@ShakataGaNai
Created November 1, 2017 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShakataGaNai/a9620ff0a9610e2a2d61813872134db3 to your computer and use it in GitHub Desktop.
Save ShakataGaNai/a9620ff0a9610e2a2d61813872134db3 to your computer and use it in GitHub Desktop.
Load every JPG file in the current directory and strip all the exif from it.
from PIL import Image
import re
from os import listdir
from os.path import isfile, join
def clean(f):
image_file = open(f)
image = Image.open(image_file)
data = list(image.getdata())
image_without_exif = Image.new(image.mode, image.size)
image_without_exif.putdata(data)
image_without_exif.save(f)
onlyfiles = [f for f in listdir('./') if isfile(join('./', f))]
for file in onlyfiles:
if file.endswith(".jpg"):
print(file)
clean(file)
print("done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment