Herpy dooves.
parent
8ee60a5135
commit
6793326ec9
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- encoding: utf-8 -*-
|
||||
from papiezator.pope_utils import get_pope, redis_me
|
||||
from django.http import HttpResponse
|
||||
from io import BytesIO
|
||||
from PIL import Image
|
||||
|
||||
|
||||
# FIXME: kind of fugly.
|
||||
@redis_me("noir_pope")
|
||||
def get_noir_pope(width, height, pope_id):
|
||||
pope_buffer = BytesIO()
|
||||
pope = get_pope(width, height, pope_id)
|
||||
if not pope:
|
||||
return None
|
||||
|
||||
pope = Image.open(BytesIO(pope)).convert("L")
|
||||
|
||||
pope.save(pope_buffer, "jpeg")
|
||||
pope = pope_buffer
|
||||
pope.seek(0)
|
||||
return pope.read()
|
||||
|
||||
|
||||
def view(request, width, height, pope_id=0):
|
||||
width, height = int(width), int(height)
|
||||
pope = get_noir_pope(width, height, pope_id)
|
||||
if pope:
|
||||
return HttpResponse(
|
||||
pope,
|
||||
content_type="image/jpeg"
|
||||
)
|
||||
return HttpResponse(':c')
|
Loading…
Reference in New Issue