forked from CGM_Public/pretix_original
Thumbnails: Keep frame durations of GIFs (#4183)
This commit is contained in:
@@ -180,7 +180,11 @@ def create_thumbnail(source, size, formats=None):
|
|||||||
except:
|
except:
|
||||||
raise ThumbnailError('Could not load image')
|
raise ThumbnailError('Could not load image')
|
||||||
|
|
||||||
frames = [resize_image(frame, size) for frame in ImageSequence.Iterator(image)]
|
frames = []
|
||||||
|
durations = []
|
||||||
|
for f in ImageSequence.Iterator(image):
|
||||||
|
durations.append(f.info.get("duration", 1000))
|
||||||
|
frames.append(resize_image(f, size))
|
||||||
image_out = frames[0]
|
image_out = frames[0]
|
||||||
save_kwargs = {}
|
save_kwargs = {}
|
||||||
source_ext = os.path.splitext(source_name)[1].lower()
|
source_ext = os.path.splitext(source_name)[1].lower()
|
||||||
@@ -198,6 +202,8 @@ def create_thumbnail(source, size, formats=None):
|
|||||||
'loop': image.info.get('loop', 0),
|
'loop': image.info.get('loop', 0),
|
||||||
'save_all': True,
|
'save_all': True,
|
||||||
}
|
}
|
||||||
|
if len(frames) > 1 and 'duration' in image.info:
|
||||||
|
save_kwargs['duration'] = durations
|
||||||
else:
|
else:
|
||||||
target_ext = 'png'
|
target_ext = 'png'
|
||||||
quality = None
|
quality = None
|
||||||
|
|||||||
Reference in New Issue
Block a user