master
daz 2013-11-24 02:32:32 +01:00
parent 7797b2e8e9
commit 1bd15b9107
2 changed files with 18 additions and 2 deletions

View File

@ -3,6 +3,11 @@ from PIL import Image
from os import path
PREFIX = "popes"
def select_best_pope(width,height):
return "papiez.jpg"
class PopeMaster:
def __init__(self):
pass

View File

@ -1,6 +1,9 @@
# Create your views here.
from django.shortcuts import render
from django.http import HttpResponse
from PIL import Image
from io import BytesIO # FIXME:
from papiezator.pope_utils import select_best_pope
def index(request):
@ -10,6 +13,14 @@ def index(request):
pass
def conclave(request, width, height):
width, height = int(width), int(height)
with open("papiez.jpg", "rb") as file:
return HttpResponse(file.read(), mimetype="image/jpeg")
pope = select_best_pope(width, height)
im = Image.open(pope)
im = im.resize((width, height))
f = BytesIO()
im.save(f, "jpeg")
f.seek(0)
return HttpResponse(f.read(), mimetype="image/jpeg")