Skip to content
Permalink
Browse files
wrap EXIF data copying behind a flag
  • Loading branch information
ralsina committed Jan 4, 2016
1 parent 5e6f41c commit 4f01ad6e8467d9711c44810d6015c9bfe1fee497
Showing with 13 additions and 8 deletions.
  1. +5 −0 nikola/conf.py.in
  2. +1 −4 nikola/image_processing.py
  3. +1 −0 nikola/nikola.py
  4. +3 −2 nikola/plugins/task/galleries.py
  5. +3 −2 nikola/plugins/task/scale_images.py
@@ -562,6 +562,11 @@ GITHUB_COMMIT_SOURCE = True
#
# If set to False, it will sort by filename instead. Defaults to True
# GALLERY_SORT_BY_DATE = True

# If set to True, EXIF data will be copied when an image is thumbnailed or
# resized.
# PRESERVE_EXIF_DATA = False

#
# Folders containing images to be used in normal posts or pages. Images will be
# scaled down according to IMAGE_THUMBNAIL_SIZE and MAX_IMAGE_SIZE options, but
@@ -52,7 +52,7 @@ class ImageProcessor(object):

image_ext_list_builtin = ['.jpg', '.png', '.jpeg', '.gif', '.svg', '.bmp', '.tiff']

def resize_image(self, src, dst, max_size, bigger_panoramas=True):
def resize_image(self, src, dst, max_size, bigger_panoramas=True, preserve_exif_data=False):
"""Make a copy of the image in the requested size."""
if not Image or os.path.splitext(src)[1] in ['.svg', '.svgz']:
self.resize_svg(src, dst, max_size, bigger_panoramas)
@@ -83,9 +83,6 @@ def resize_image(self, src, dst, max_size, bigger_panoramas=True):
elif value == 8:
im = im.rotate(90)
break
#if decoded == 'XResolution':
#self.logger.warning('POP')
#exif.pop(tag)
try:
im.thumbnail(size, Image.ANTIALIAS)
if _exif is not None:
@@ -452,6 +452,7 @@ def __init__(self, **config):
'POSTS_SECTION_FROM_META': False,
'POSTS_SECTION_NAME': "",
'POSTS_SECTION_TITLE': "{name}",
'PRESERVE_EXIF_DATA': False,
'PAGES': (("stories/*.txt", "stories", "story.tmpl"),),
'PANDOC_OPTIONS': [],
'PRETTY_URLS': False,
@@ -86,6 +86,7 @@ def set_site(self, site):
'tzinfo': site.tzinfo,
'comments_in_galleries': site.config['COMMENTS_IN_GALLERIES'],
'generate_rss': site.config['GENERATE_RSS'],
'preserve_exif_data': site.config['PRESERVE_EXIF_DATA'],
}

# Verify that no folder in GALLERY_FOLDERS appears twice
@@ -475,7 +476,7 @@ def create_target_images(self, img, input_path):
'targets': [thumb_path],
'actions': [
(self.resize_image,
(img, thumb_path, self.kw['thumbnail_size']))
(img, thumb_path, self.kw['thumbnail_size'], preserve_exif_data=self.kw['preserve_exif_data']))
],
'clean': True,
'uptodate': [utils.config_changed({
@@ -490,7 +491,7 @@ def create_target_images(self, img, input_path):
'targets': [orig_dest_path],
'actions': [
(self.resize_image,
(img, orig_dest_path, self.kw['max_image_size']))
(img, orig_dest_path, self.kw['max_image_size'], preserve_exif_data=self.kw['preserve_exif_data']))
],
'clean': True,
'uptodate': [utils.config_changed({
@@ -71,8 +71,8 @@ def process_tree(self, src, dst):

def process_image(self, src, dst, thumb):
"""Resize an image."""
self.resize_image(src, dst, self.kw['max_image_size'], False)
self.resize_image(src, thumb, self.kw['image_thumbnail_size'], False)
self.resize_image(src, dst, self.kw['max_image_size'], False, preserve_exif_data=self.kw['preserve_exif_data'])
self.resize_image(src, thumb, self.kw['image_thumbnail_size'], False, preserve_exif_data=self.kw['preserve_exif_data'])

def gen_tasks(self):
"""Copy static files into the output folder."""
@@ -82,6 +82,7 @@ def gen_tasks(self):
'image_folders': self.site.config['IMAGE_FOLDERS'],
'output_folder': self.site.config['OUTPUT_FOLDER'],
'filters': self.site.config['FILTERS'],
'preserve_exif_data': self.site.config['PRFESERVE_EXIF_DATA'],
}

self.image_ext_list = self.image_ext_list_builtin

0 comments on commit 4f01ad6

Please sign in to comment.