0

I want to get an extension (or HTTP headers received) and base64-encoded (seems like JS doesn't have a built-in encoding function, so "binary" would be ok too) body of an image on a page. How can I do it?

This probably seems to be a weird action, but I really need to do it this way: I have a browser object and want to get such data from the last loaded page. The driver supports executing JS in the context of the current page so I think it is probably the best solution.

Update:

See, I already have a page with all the images on it and I don't want to request any of them again. I want to get the data string (like "GIF89a��÷–�Òíÿ…™ë�•懚í~’âÔîÿ}‘à‡�¤ÇãÿÓÕ䊜ë) of a certain image.

Fluffy
  • 27,504
  • 41
  • 151
  • 234

2 Answers2

2

This question is a duplicate, and has been answered, albeit with a lot of discussion.

Another idea: If you can influence the source document, you could embed all images as inline images. The "src" attribute should then contain the whole base64 string, however I have never tried this out.

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
1

Just use XmlHttpRequest to fetch the image? http://codingforums.com/showthread.php?t=141041

Do we mean "formatting the received data and display an hex dump"? You can probably consult a previous post related to this topic: Is there a way to read binary data in JavaScript?

Community
  • 1
  • 1
jldupont
  • 93,734
  • 56
  • 203
  • 318
  • If the image is cacheable (policy returned through the HTTP headers) then the browser might fetch it from its cache. – jldupont Nov 22 '09 at 15:27