Skip to content
Browse files
full EXIF stripping works
  • Loading branch information
ralsina committed Jul 18, 2016
1 parent c53ad18 commit 84115e6cb7031f10d2b6054f24f70abb9a9a9687
Showing 2 changed files with 4 additions and 5 deletions.
@@ -76,7 +76,7 @@ def filter_exif(self, exif, whitelist):

# Scenario 2: keep nothing
if whitelist == {}:
return {}
return None

# Scenario 3: keep some
for k in list(exif.keys()):
@@ -93,7 +93,7 @@ def filter_exif(self, exif, whitelist):
if EXIF_TAG_NAMES[tag] not in whitelist[k]:

return exif
return exif or None

def resize_image(self, src, dst, max_size, bigger_panoramas=True, preserve_exif_data=False, exif_whitelist={}):
"""Make a copy of the image in the requested size."""
@@ -132,7 +132,7 @@ def resize_image(self, src, dst, max_size, bigger_panoramas=True, preserve_exif_
exif = self.filter_exif(exif, exif_whitelist)
im.thumbnail(size, Image.ANTIALIAS)
if exif is not None and preserve_exif_data:
if exif is not None and preserve_exif_data and '0th' in exif:
# Put right size in EXIF data
w, h = im.size
exif["0th"][piexif.ImageIFD.XResolution] = (w, 1)
@@ -652,8 +652,7 @@ def __init__(self, **config):

# Setting PRESERVE_EXIF_DATA with an empty EXIF_WHITELIST implies 'keep everything'
if self.config['PRESERVE_EXIF_DATA'] and not self.config['EXIF_WHITELIST']:
utils.LOGGER.warn('Setting PRESERVE_EXIF_DATA and not EXIF_WHITELIST implies all EXIF data will be kept.')
self.config['EXIF_WHITELIST'] = {"*": "*"}
utils.LOGGER.warn('You are setting PRESERVE_EXIF_DATA and not EXIF_WHITELIST so EXIF data is not really kept.')

# Handle CONTENT_FOOTER properly.
# We provide the arguments to format in CONTENT_FOOTER_FORMATS.

0 comments on commit 84115e6

Please sign in to comment.