Embedding images in HTML

I was creating a small dialog in an .hta file and to make a little prettier for the user I included a company logo:

SNAGHTMLdfa805

But I wanted to deploy the .hta as a single file.

And this can be done using data: followed by a base64 encoded png:

<img  src="data:image/png;base64,

The Base64 encoding can easily be done with PowerShell:

function ConvertTo-Base64($path)
{
	return [Convert]::ToBase64String((Get-Content $path -Encoding byte))
}

ConvertTo-Base64 "Picture.png"

Example:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADUAAAArCAIAAABXWFfMAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAaBJREFUWEftmNsOwyAIhrv3f+iuU2eonA9LXFLTq03sJz8I9nWe57HzuPh2HsfOcB9tH76UB2r8hxMsBQWMg3wLUIuT24MmBIEjfNe7MZD8SzOJDJ9Z94oXrs//2voorXwZMrgfL6WJL+wzztN2uXW+crgpt0VphY+H64sHY9GOGODD25Yp53ziDFJdKPFRzuMWJBHJyesxKSOyfIyyTdT7YITmZq5RIecKzSfAMXw4Fq18fb+CLsRfab6xJl/lrCq7/Dcm1+pb6L8/4CP9zZ0vev6qByHxPlvBsJ/P7Pm31GVuN+vvNr5U5SD7xYcvUY65I9B7vhTLGsmPXiHwfSLZrQjmBfXjp0lTw1fV4gNNh0oFfHjRsNyzPM4V3HxkCFYhLqES6a9GcaCuknmVIZ96UQr0971diz/TXIXrTaU0OJQMYiWfHIiq1kunCOdbnKf7TwhEmH0kh0BvhLPyzTtHJuxiX2H07wcwPFVB5SJmdxvsGeUMsd+epIwOkM0G2M1HXTGJfgIGZeQdzcanL3tLRQkSBloMa/iqaPA6u/O9ARufjI6hiJD2AAAAAElFTkSuQmCC" />
</PRE