axeII / kaliya

image downloader
MIT License
2 stars 0 forks source link

Automatically remove any meta data from image #5

Open axeII opened 5 years ago

axeII commented 5 years ago

Thanks to this will be downloading images with kaliya more privacy friendly since facebook is adding own metadata into images to track users.

axeII commented 5 years ago
# Uses the Python Imaging Library
# `pip install Pillow` works too
from PIL import Image

image_filename = "picture_with_EXIF.jpg"
image_file = open('image_filename)
image = Image.open(image_file)

# next 3 lines strip exif
image_data = list(image.getdata())
image_without_exif = Image.new(image.mode, image.size)
image_without_exif.putdata(image_data)

image_without_exif.save(u"clean_{}".format(image_filename))