> -----Ursprüngliche Nachricht-----
> Von: [email protected] 
> [mailto:[EMAIL PROTECTED] Im Auftrag von deezee
> Gesendet: Dienstag, 3. Juni 2008 23:05
> An: pylons-discuss
> Betreff: How to pass image?
> 
> 
> Hello everybody!
> I'm pretty new in Pylons world - today i downloaded and 
> installed software. So, some stupid question:
> 
> How to send (simplest way) image from PIL to template  
> (browser) without saving file?
> I'm playing around helloworld sample, but i want to see 
> picture instead of text. I can generate one by PIL, and send 
> by c.image, but till now i just have <PIL.Image......> 
> marker, no image itself.
> In PHP it's quite simple, don't believe something newer is 
> more complicated..

Inside of the controller action:
1. you generate a image with PIL
2. you convert the stuff to string with a certain format (I do this with
reportlab charts like: binaryStuff = drawToString(d, 'png'))
3. you set the content header to the corresponding format
(response.headers['Content-type'] = 'image/png')
4. you return the string (return binaryStuff)

This controller action is only for serving the image requests! In you HTML
(maybe generated by MAKO) you have to have a <img> - tag which points to the
controller action.

For example:
- action "index"  -> serves HTML, and returns HTML with <img
src="/picture1">
- action "picture1" -> serves PNG pictures

A very rough draft, but hopefully points you to the right direction.

Andrew


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to