All Articles Kinsa Creative

Remove Meta Data from an Image in Python with PIL

EXIF meta data can be stripped from an image with the Pillow library by opening the image, creating a new image without copying the meta data, and saving. Doing this requires loading the entire image into memory before it is written.

Install the Pillow library

$ pip install pillow

Remove EXIF Data by Replicating the Image via PIL

from PIL import Image

image ='/path/to/file.jpg')
data = list(image.getdata())
image2 =, image.size)

Retaining or Reading EXIF Data from an Image Using PIL

If you wish to retain EXIF data from the original to the copied image, you need to do so explicitly by reading the EXIF data from the image and setting it via the exif kwarg on save:

exif =['exif']'/path/to/newfile.jpg', exif=exif)

To print EXIF data from an image:

from PIL import Image
from PIL.ExifTags import TAGS

image ='/path/to/file.jpg')
for tag, value in image._getexif().items():
    print(TAGS.get(tag), value)


Email us at