Jarek Zgoda wrote: > You can just return the content (bytes) in HttpResponse with > appropriate content-type header. First argument to HttpResponse > constructor is the content.
if you're using PIL to create the image, you can (usually) save the image to the response object, e.g. response = HttpResponse(mimetype="image/jpeg") image.save(response, "JPEG") the response object doesn't provide the full file API, so some less commonly used file format drivers may fail when doing this (usually because they need "seek"). common web formats work fine, though. if you want to support more than one format, you can use PIL's MIME-type registry to simplify things a bit: from PIL import Image Image.init() # explicitly load available file format drivers ... def myview(...): format = "PNG" response = HttpResponse(mimetype=Image.MIME[format]) image.save(response, format) ... you may e.g. want to use "JPEG" for truecolor and grayscale images, and "PNG" for palette and bitone images: if image.mode == "P" or image.mode == "1": format = "PNG" else: format = "JPEG" </F> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---