Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML: How can I display an image using just its hex representation [duplicate]

Tags:

html

css

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?

like image 557
Nerian Avatar asked Dec 04 '22 22:12

Nerian


2 Answers

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.

like image 133
alex Avatar answered Dec 08 '22 16:12

alex


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
like image 25
Sam Magura Avatar answered Dec 08 '22 14:12

Sam Magura