From 23a81923aa2d0a8a7cacfc9f670b31c9aa97bff6 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Mon, 16 Nov 2020 07:55:18 +0000 Subject: [PATCH] Added exception catching to the photo endpoint, for cases where conversion fails (we just had one case of RGBA to JPEG didn't work). - Legacy-Id: 18697 --- ietf/person/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ietf/person/views.py b/ietf/person/views.py index 87e8137d9..1cebd34e5 100644 --- a/ietf/person/views.py +++ b/ietf/person/views.py @@ -99,8 +99,11 @@ def photo(request, email_or_name): img = Image.open(person.photo) img = img.resize((size, img.height*size//img.width)) bytes = BytesIO() - img.save(bytes, format='JPEG') - return HttpResponse(bytes.getvalue(), content_type='image/jpg') + try: + img.save(bytes, format='JPEG') + return HttpResponse(bytes.getvalue(), content_type='image/jpg') + except OSError: + raise Http404 @role_required("Secretariat")