cazala / synaptic

architecture-free neural network library for node.js and the browser
http://caza.la/synaptic
Other
6.91k stars 666 forks source link

The canvas has been tainted by cross-origin data. #301

Closed ghost closed 4 years ago

ghost commented 6 years ago

If someone can help me, I appreciate it.

I tried to replicate the 'paint an image' code but when I try to draw the new image the following error occurs:

Uncaught DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data. at getData (file:///C:/Users/Neto-PC/Documents/Inteligencia%20Artificial/RedeNeuralJS/RedeJS.js:40:29) at inicio (file:///C:/Users/Neto-PC/Documents/Inteligencia%20Artificial/RedeNeuralJS/RedeJS.js:47:16) at file:///C:/Users/Neto-PC/Documents/Inteligencia%20Artificial/RedeNeuralJS/RedeJS.js:92:1


My code: https://github.com/NetonD/Synaptic-JS-Rede-Neural

jbhurruth commented 6 years ago

When you run a web page straight from your file system the browser will not consider the files to be from the same 'origin'. Loading images from sources that aren't part of the same origin will have certain limitations applied to them by the browser. This is for security reasons to stop malicious code from origins that are not under your control from attacking your page. For more information check out MDN: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

TL;DR: If you run up a web server to serve your code you'll avoid this problem. If you haven't got a web server such as Apache installed, I recommend you install node.js and follow these instructions: https://stackoverflow.com/a/16350826