Skip to content

Commit

Permalink
fix: Handle JPEGs identified as MPOs
Browse files Browse the repository at this point in the history
  • Loading branch information
honzajavorek committed Feb 5, 2018
1 parent 947b3d9 commit 93feae1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions danube_delta/cli/photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,21 @@ def import_image(src_filename, dest_filename):

click.echo('Saving: {}'.format(dest_filename))
options = dict(IMAGE_SAVE_OPTIONS)
if is_animated(image):
if is_animated_gif(image):
options.setdefault('save_all', True)
image.save(dest_filename, image.format, **options)

image.save(dest_filename, get_format(image), **options)

def is_animated(image):
return len(list(ImageSequence.Iterator(image))) > 1

def is_animated_gif(image):
return (
get_format(image) == 'GIF' and
len(list(ImageSequence.Iterator(image))) > 1
)


def get_format(image):
return 'JPEG' if image.format == 'MPO' else image.format


def find_last_article(content_dir):
Expand Down

0 comments on commit 93feae1

Please sign in to comment.