Agha
Agha

Reputation: 67

string image data in html

I'd like to know if it's possible to assign image data as text to an image in HTML form instead of setting it's "src" property to a file path... i want to do it with PHP!...

i remember seeing something like the following code in some websites' source... for example:

image data = R6+1u5jwhwf6GOG6X6MpFR/hrlbNA1JcqeByPKDIivcJQa2ePIft0Jqewk4/lLYSy4YU1BXARkvdN7vJxx0vUOJGiU5OiMhMhWrH6s1n3pGK0Sat0mMiUCQX4e4BDU+yD1kB87tI+Xh+WitqNN7FyLysoGlAvsGfZQ2bOo+7+7Bm6K4NMktamfNG9v

in this way... by viewing the source of my webpage... it's not possible to see the address of the images used! just it's data! i think it's more secure! MAYBE!

Thanks!

Upvotes: 0

Views: 1356

Answers (4)

dav
dav

Reputation: 9277

if you have image data you can show image on html page like this <img src="data:image/png;imagedatacodehere" /> , if it has png extension, check this link

Upvotes: 1

Marc B
Marc B

Reputation: 360882

Yes, it's possible, no it's not more secure. You're talking about data uris, and since the user's browser has to have the image data in order to display the image, you're still sending the picture to the user. All they have to do is right-click/save as on the displayed and boom, done. Also, the image data is just embedded in base64 format into the page itself, meaning you can trivially cut/paste that base64 string and still steal the image, even if you have all kinds of pointless image protection (e.g. right-click disablers).

Upvotes: 0

quickshiftin
quickshiftin

Reputation: 69781

I think what you're referring to is Base64 encoded images in HTML.

It's not very portable though, not nearly as much as a standard img tag.

Upvotes: 1

emartel
emartel

Reputation: 7773

It is not more secure as the picture has to be created in the browser to be displayed by the user.

What you could do (which won't make it any more "secure"), is to have a PHP script that translates your "data" into an image, see this thread for an idea on how to do this!

Upvotes: 2

Related Questions