String Literal to Blob

Steve Holden steve at holdenweb.com
Sun Apr 13 08:05:53 EDT 2008


Jason Scheirer wrote:
[...]
> 
> There _is_ a way to embed image data in HTML that is supported by
> every major browser. It is ugly. Using the RFC 2397 (http://
> www.ietf.org/rfc/rfc2397) spec for data URLs you could go
> 
> '<img src="data:image/jpg;base64,%s">' % base64.b64encode(image_data)
> 
> Obviously you need to import the base64 module somewhere in your code
> and base64-encoded data is about a third larger than it would be
> otherwise, so embedding anything particularly large is going to be a
> huge pain and affect page load times pretty badly.

This is hardly likely to help someone who hasn't yet grasped the concept 
of referencing graphics and prefers to write database output to disk to 
serve it statically. But who knows, maybe it will ...

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list