master
daz 2013-11-25 19:55:23 +01:00
parent 73e08cfdd6
commit 3af1d97d7a
2 changed files with 15 additions and 10 deletions

View File

@ -22,3 +22,7 @@ class PopeVersion(models.Model):
class PerfectPope(models.Model):
aspect_ratio = models.DecimalField(max_digits=6, decimal_places=decimal_places)
pope = models.ForeignKey('Pope')
def __str__(self):
return str(self.aspect_ratio)

View File

@ -14,14 +14,15 @@ def index(request):
def conclave(request, width, height):
width, height = int(width), int(height)
if width > 0 and height > 0:
aspect_ratio = width/height
pope = select_best_pope(aspect_ratio)
aspect_ratio = width/height
pope = select_best_pope(aspect_ratio)
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")
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")
else:
return HttpResponse("8====D~~~~")