Search code examples
javascripthtmldata-uri

Converting remote Image to dataURL, client-side


Possible Duplicate:
Get image data in Javascript?
Convert an image into binary data in javascript

I have:

A string containing a link to an image on a remote server.

I want:

To 'get' this image, purely through client-side Javascript, and convert it to a base64 dataURL representation.

Is this possible? How?


Solution

  • You can not.

    Because the file is on a remote server, you can't use the canvas element's getImageData() method to get the pixel representation of the image.

    You'd need to proxy it via a server side script or similar.