How do canvas toDataURL work on images on another server?

Asked

Viewed 60 times

0

I have a Facebook app where I get a picture of the user’s profile. How to paste this image over another one by making a montage to be then shared on fb itself. The canvas toDataURL method does not work because the image is on another server. I need some plugin or something like?

  • Friend, from what I saw here, the toDataUrl method of canvas, has no domain restrictions. When you try to use it, which error is triggered on the console?

  • Does not trigger any error, only the image does not appear

  • from what I have read, this restriction occurs so that there is no copying or falsification of copyright images or anything like

  • You’re right. From what I saw here, the solution would be for you to use a server, in backend you wouldn’t have that kind of restriction

  • LF Ziron how so? You have some link where I can learn to do this?

  • 1

    I solved the problem. Just do: img.crossOrigin = "Anonymous";

  • Create an answer to your question with this information, so when another user has the same question, they will find a solution more easily

Show 2 more comments

1 answer

0

I solved the problem. Just do:

img.crossOrigin = "Anonymous";

Browser other questions tagged

You are not signed in. Login or sign up in order to post.