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
This commit is contained in:
parent
49f6f8961e
commit
23a81923aa
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue