You want something like this:

        image = Image.open('/home/www-data/html/picture_lib/0002/0002.jpg')
        response = HttpResponse(mimetype='image/jpeg')
        image.save(response, "JPEG")
        return response()

The response object is file-like, you can write your content data to it, 
and the image.save() method takes a file-like object and writes the 
image data to it.

--Ned.

Lasse Borchard wrote:
> Hi all,
>
> one simple quest, but i dont find anything at google...
> Ive an image gallery and i dont want to store the images
> in my "static" (handler none) directory, because to view 
> the image it is necesaary to be logged in.
> Therefore django must serve the images. But i'm sadly still
> a newbie. 
>
> I tried like this:
>
> from django.http import HttpResponse, HttpResponseRedirect, HttpRequest
> import os, glob, re
> # from project_knauf.login import login
> from PIL import Image, ImageOps
>
> def foobar(request):
>       image = Image.open('/home/www-data/html/picture_lib/0002/0002.jpg')
>       response = HttpResponse(content='image',mimetype='image/jpeg')
>       return response()
>
> Is it completely wrong? Please help... 
>
> Thanks, Lasse
>
> >
>
>
>
>   

-- 
Ned Batchelder, http://nedbatchelder.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to