Did you know you could embed any mime data in an HTML page? I didn't. What does this mean?
It means you can place an image inline in a page.
data:<mimetype>;base64,<data> is how you code it. The example here is a base64 PNG, taken straight from rifers.org.
Which is cool, but has high potential for evil. Which makes me think that it will be (or already is) be used in that way. Which means that it will probably (or should) disappear from browsers.
But it is a neat thing I never knew about. It does only work in Firefox, Safari, Opera. Not IE. (via)
Tagged As HTML
Comments are Open (3)
Posted at 08:11 AM
Comments
Richard@Home
Now that IS cool, especially if you want to produce stand alone documents (reports with graphs and no dependencies for instance).
What tool did you use to produce the
img src="data:image/png;base64,iVBORw0KGgoAAAANSUh...
string?
Posted by: Richard@Home | April 12, 2005 09:50 AM
Tony
I cheated. I just copied the source of the image from their site.
I've done some quick experimenting in trying to getting the code of the image. If you try and open an image file into a text editor it doesn't work in this instance. The source needs to be base64. That's the important step.
Posted by: Tony
|
April 12, 2005 09:59 AM
dysfunksional.monkey
Quick way of getting the information using PHP:
<?php
$image = $_GET['imgsrc'];
list(, , , $attr, $mime) = getimagesize($image);
echo '<img src="data:'.$mime.';base64,'.base64_encode(file_get_contents($image)).'" '.$attr.' />';
?>
This will produce the image tag directly on the page for you to copy and paste.
Posted by: dysfunksional.monkey | April 13, 2005 03:13 AM