0

Is it possbile to get data of the remote image which is on the remote server in pure Angular? Without using PHP Curl or similar things.

Alliswell
  • 1,523
  • 20
  • 35
  • In English? I really don't understand your question. – Michael May 19 '15 at 12:26
  • @Michael, I'm wondering if it is possible to get base64 data from the remote image? Somehow in pure Angularjs or JS? – Alliswell May 19 '15 at 12:35
  • I think he wants to get the byte array of an image from a remote server purely in Angular. The question I have is why? Is there something in specific you want to do with the image? – Maurice Reeves May 19 '15 at 12:36
  • You wanna load a base64 encoded image from a server? In that case the server has to return the encoded image. If you want to load a remote image and convert it to base64 see [here](http://stackoverflow.com/questions/6150289/how-to-convert-image-into-base64-string-using-javascript) – Michael May 19 '15 at 12:39
  • @MauriceReeves, I want to load remote images to my server and before save resize it via HTML5 canvas. The problem is I don't know how to get access to this image having only it link. – Alliswell May 19 '15 at 13:01
  • What I want is shown in this [fiddle](http://jsfiddle.net/handtrix/YvQ5y/) – Alliswell May 20 '15 at 06:38
  • In fact, the answer is `img.crossOrigin = "Anonymous";` – Alliswell May 20 '15 at 07:05

1 Answers1

0

If you want to do this, you'll probably need to use a method to convert the data. Firefox and Webkit both have a method to convert a binary stream into something that the canvas can use.

I think this question will get you most of the way to where you need to go:

Converting bytes to an image for drawing on a HTML5 canvas

Cheers.

Community
  • 1
  • 1
Maurice Reeves
  • 1,572
  • 13
  • 19