Just Launched: You can now import projects and releases from Google Code onto SourceForge
We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps. Read More
From: Colin Gillespie <C.G<illespie@ne...> - 2004-04-27 13:34:34
I'm grabbing Base64 encoded text from a database and which to decode =
and display it has a picture (jpeg). How should I do this?
I can get the text and decode it OK, I just don't know how to display =
the resulting image.
From: Andy Smith <asmith@pr...> - 2004-04-27 14:02:10
Colin Gillespie wrote:
> I'm grabbing Base64 encoded text from a database and which to
> decode and display it has a picture (jpeg). How should I do this?
> I can get the text and decode it OK, I just don't know how to
> display the resulting image.
It sounds like you need something like this example:
All it does is set the content type header to let the browser know you're
sending an image not an HTML page (in your case you'll want image/jpeg not
image/gif) and then outputs the image file content. If you've already got
the image data in a variable (after extracting it and decoding from base64)
use that instead of the include.dump(...) bit.
If you have a file like this called image.spy you can then use it like any
other image URL, eg:
<img src="image.spy" alt="..." />
This is assuming your data is already encoded in JPEG format, so you just
need to output it. If it's in another format you'll need to convert it
first - the Python Imaging Library may help: