accessing/encoding images

N

Neil

Is there any way to access the image files referenced in the src
attribute of img elements using client-side javascript? It doesn't
seem like a real security issue, given that you can simply right-click/
copy/paste any image in your browser, yet I can't seem to find a way.
If not, is there a way to encode images to strings such that they can
be manipulated that way? You can create an image inline in javascript
in the following manner: <img src="data:image/gif;base64,AAABAAEAEB...
(...the rest of the base64 string)...>
Is there any way to go the other direction? To take an image from the
page and convert/encode it to a string?
Ultimately, I'm looking to create a post action that includes an image
from a page (or even simply a URI to an image, e.g.,
http://www.google.com/images/logo.gif). It's looking more and more
like the only solution is simply to get the URI client-side and
retrieve the image server-side. This has some drawbacks for me, so I
was hoping someone here might be able to help.

Thanks for your time,
Neil
 
T

Thomas 'PointedEars' Lahn

Neil said:
Is there any way to access the image files referenced in the src
attribute of img elements using client-side javascript?

Generally, most certainly yes. In the sandbox, very unlikely; at least
not everywhere.
It doesn't seem like a real security issue, given that you can simply
right-click/ copy/paste any image in your browser,

It would be a good idea to have a look at the Gecko source then. Gecko,
although written mostly in C++, uses XUL, and that functionality might
be implemented through scripted XPCOM interfaces.
yet I can't seem to find a way.

That is because additional interfaces are required for that which are not
available in the sandbox.
If not, is there a way to encode images to strings such that they can
be manipulated that way? You can create an image inline in javascript
in the following manner: <img src="data:image/gif;base64,AAABAAEAEB...
(...the rest of the base64 string)...>
Is there any way to go the other direction? To take an image from the
page and convert/encode it to a string?

What is copied there would have to contain byte data which could be
represented/stored as a string. But if you already have the `data' URL,
would it not be easier to retrieve the value of the `src' attribute instead?
Ultimately, I'm looking to create a post action that includes an image
from a page (or even simply a URI to an image, e.g.,
http://www.google.com/images/logo.gif).

Unless this is for a browser extension, the Same Origin Policy prevents
you from doing that only client-side.
It's looking more and more like the only solution is simply to get the
URI client-side

You cannot do that either inside the sandbox.
and retrieve the image server-side. This has some drawbacks for me, so I
was hoping someone here might be able to help.

You could use a server-side script to retrieve the image data, but the
copyright issue would remain.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,108
Latest member
AlbertEste
Top