Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
wrap EXIF data copying behind a flag
  • Loading branch information
ralsina committed Jan 4, 2016
1 parent 5e6f41c commit 4f01ad6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions nikola/conf.py.in
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions nikola/image_processing.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions nikola/nikola.py
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions nikola/plugins/task/galleries.py
Expand Up @@ -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
Expand Down Expand Up @@ -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({
Expand All @@ -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({
Expand Down
5 changes: 3 additions & 2 deletions nikola/plugins/task/scale_images.py
Expand Up @@ -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."""
Expand All @@ -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
Expand Down

0 comments on commit 4f01ad6

Please sign in to comment.