master
parent
73e08cfdd6
commit
3af1d97d7a
|
@ -22,3 +22,7 @@ class PopeVersion(models.Model):
|
||||||
class PerfectPope(models.Model):
|
class PerfectPope(models.Model):
|
||||||
aspect_ratio = models.DecimalField(max_digits=6, decimal_places=decimal_places)
|
aspect_ratio = models.DecimalField(max_digits=6, decimal_places=decimal_places)
|
||||||
pope = models.ForeignKey('Pope')
|
pope = models.ForeignKey('Pope')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
|
||||||
|
return str(self.aspect_ratio)
|
||||||
|
|
|
@ -14,14 +14,15 @@ def index(request):
|
||||||
|
|
||||||
def conclave(request, width, height):
|
def conclave(request, width, height):
|
||||||
width, height = int(width), int(height)
|
width, height = int(width), int(height)
|
||||||
|
if width > 0 and height > 0:
|
||||||
|
aspect_ratio = width/height
|
||||||
|
pope = select_best_pope(aspect_ratio)
|
||||||
|
|
||||||
|
im = Image.open(pope)
|
||||||
aspect_ratio = width/height
|
im = im.resize((width, height))
|
||||||
pope = select_best_pope(aspect_ratio)
|
f = BytesIO()
|
||||||
|
im.save(f, "jpeg")
|
||||||
im = Image.open(pope)
|
f.seek(0)
|
||||||
im = im.resize((width, height))
|
return HttpResponse(f.read(), mimetype="image/jpeg")
|
||||||
f = BytesIO()
|
else:
|
||||||
im.save(f, "jpeg")
|
return HttpResponse("8====D~~~~")
|
||||||
f.seek(0)
|
|
||||||
return HttpResponse(f.read(), mimetype="image/jpeg")
|
|
||||||
|
|
Loading…
Reference in New Issue