From e16d71bd2a597c45f7a5cb02248b6ed93cecec54 Mon Sep 17 00:00:00 2001 From: Bobby Date: Mon, 1 May 2023 04:09:30 -0400 Subject: Added animation support in GIF images in articles --- ignis/views.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ignis/views.py b/ignis/views.py index 0f3d6a3c..454b63a6 100644 --- a/ignis/views.py +++ b/ignis/views.py @@ -88,9 +88,13 @@ def get_image(request, post_id, image_name): image_file = f.read() # convert to gif image = Image.open(BytesIO(image_file)) - output = BytesIO() - image.save(output, format='GIF') - return HttpResponse(output.getvalue(), content_type='image/gif') + # check image format + if image.format != 'GIF': + image = image.convert('RGBA') + output = BytesIO() + image.save(output, format='GIF') + image_file = output.getvalue() + return HttpResponse(image_file, content_type='image/gif') @csrf_exempt def cover_image(request, repository): -- cgit v1.2.3