Implement the pagan lib (for fun)

This commit is contained in:
Oliver Falk
2019-02-28 17:02:15 +01:00
parent c977411309
commit 2d62e658e4
2 changed files with 11 additions and 1 deletions

View File

@@ -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.

View File

@@ -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