return image in mod python

Peter Otten __peter__ at web.de
Thu Nov 22 09:07:39 CET 2007


Abandoned wrote:

> Hi i have a problem.
> 
> def showimage(req):
>         from PIL import Image
>         im=Image.open("c:\image-2.jpg")
>         im.thumbnail((800,600), Image.ANTIALIAS)
>         req.sendfile(im)
> 
> 
> 
> give me some error.
> How can i return this image witdhout save ?

image = Image.open(...)
image.thumbnail(...)
req.content_type = "image/jpeg"
image.save(req, "jpeg")

Peter



More information about the Python-list mailing list