You can do it like in django:
from PIL import Image
def image():
image = Image.new("RGB", (800, 600))
response.headers['Content-Type']="image/png"
image.save(response.body, "PNG")
return response.body.getvalue()
response.body is a StringIO
On Jul 1, 4:40 am, hywang <[email protected]> wrote:
> django do it like this:
>
> from django.utils.httpwrappers import HttpResponse
> from PIL import Image
> def image(request):
> image = Image.new("RGB", (800, 600))
> response = HttpResponse(mimetype="image/png")
> image.save(response, "PNG")
> return response
>
> in web2py, I did it with a file, first i save image to a file:
> image.save("outut.png", "png")
> then stream it:
> return response.stream("output.png")
>
> is there anyway like this to do it in web2py ?
> thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---