Skip to content

Commit

Permalink
full EXIF stripping works
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Jul 18, 2016
1 parent c53ad18 commit 84115e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions nikola/image_processing.py
Expand Up @@ -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()):
Expand All @@ -93,7 +93,7 @@ def filter_exif(self, exif, whitelist):
if EXIF_TAG_NAMES[tag] not in whitelist[k]:
exif[k].pop(tag)

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."""
Expand Down Expand Up @@ -132,7 +132,7 @@ def resize_image(self, src, dst, max_size, bigger_panoramas=True, preserve_exif_
exif = self.filter_exif(exif, exif_whitelist)
try:
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)
Expand Down
3 changes: 1 addition & 2 deletions nikola/nikola.py
Expand Up @@ -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.
Expand Down

0 comments on commit 84115e6

Please sign in to comment.