Jump to content

Using Image Data


mikolaskova
 Share

Recommended Posts

Hello, 

I want to work with the image data of a jpeg-image like in this example:

https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_canvas_getimagedata2

On a webserver it works fine, but if I test locally I get an error

Quote

index.html:16 Uncaught DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.

Isn't it possible to work locally? How do I have to change the script in order to run it locally?

I will work with my (young) students with javascript and would like to work locally.

Best Regards

Link to comment
Share on other sites

Browsers have security in place to prevent local scripts from mining information from the user's computer. Aside from that, if the image you are loading is not on your computer then the cross-origin protection will apply.

I would suggest installing server software, such as XAMPP, on your computer.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...