aboutsummaryrefslogtreecommitdiff
path: root/ignis
diff options
context:
space:
mode:
authorBobby <[email protected]>2023-05-01 04:09:30 -0400
committerBobby <[email protected]>2023-05-01 04:09:30 -0400
commite16d71bd2a597c45f7a5cb02248b6ed93cecec54 (patch)
treeea7506bb45ea6791ce510d3d8da12f2886d0ded0 /ignis
parent967e3ad7cf9b4064cbd26cd7c383c16139429f12 (diff)
downloadthatcomputerscientist-e16d71bd2a597c45f7a5cb02248b6ed93cecec54.tar.xz
thatcomputerscientist-e16d71bd2a597c45f7a5cb02248b6ed93cecec54.zip
Added animation support in GIF images in articles
Diffstat (limited to 'ignis')
-rw-r--r--ignis/views.py10
1 files 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):