From 2d62e658e4cd5b0bd666211f3c0f91325389ac22 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Thu, 28 Feb 2019 17:02:15 +0100 Subject: [PATCH] Implement the pagan lib (for fun) --- ivatar/views.py | 11 ++++++++++- requirements.txt | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ivatar/views.py b/ivatar/views.py index 387c42c..4f56b43 100644 --- a/ivatar/views.py +++ b/ivatar/views.py @@ -18,7 +18,7 @@ from PIL import Image from monsterid.id import build_monster as BuildMonster import Identicon from pydenticon5 import Pydenticon5 - +import pagan from robohash import Robohash from ivatar.settings import AVATAR_MAX_SIZE, JPEG_QUALITY, DEFAULT_AVATAR_SIZE @@ -166,6 +166,15 @@ class AvatarImageView(TemplateView): data, content_type='image/png') + if str(default) == 'pagan': + img = pagan.Avatar(kwargs['digest']) + data = BytesIO() + img.img.save(data, 'PNG', quality=JPEG_QUALITY) + data.seek(0) + return HttpResponse( + data, + content_type='image/png') + if str(default) == 'identicon': p = Pydenticon5() # In order to make use of the whole 32 bytes digest, we need to redigest them. diff --git a/requirements.txt b/requirements.txt index 9a9a4dc..d2bdc99 100644 --- a/requirements.txt +++ b/requirements.txt @@ -37,3 +37,4 @@ git+https://github.com/ofalk/Robohash.git@devel python-memcached git+https://github.com/ercpe/pydenticon5.git git+https://github.com/flavono123/identicon.git +pagan