5

Possible Duplicate:
Is it possible to put binary image data into html markup and then get the image displayed as usual in any browser?

So for example I have an image like:

\x89PNG\r\n\u001A\n\u0000\u0000\u0000\rIHDR\u0000\u0000\u0001@\u0000\........

Is there any way that from that I can show the image in a img tag?

Community
  • 1
  • 1
Nerian
  • 15,901
  • 13
  • 66
  • 96

2 Answers2

11

You can't show it natively without assistance to convert it.

If you base 64 encode it instead, you can.

<img src="data:image/png;base64,iVBrkJggg==" alt="Base 64 encoded!" />

Further Reading.

alex
  • 479,566
  • 201
  • 878
  • 984
5

You can't do that with HTML only. The img tag can only display images via the URL supplied in the src attribute. You could set src to the URL of a page on your server that prints the hex string. For example:

<img src="myimage.php" />

myimage.php:

header("Content-type: image/png")
print $hex_string
Sam Magura
  • 850
  • 8
  • 18