Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support images from arbitrary origins #14

Open
smketterer opened this issue Jan 11, 2022 · 2 comments
Open

Support images from arbitrary origins #14

smketterer opened this issue Jan 11, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@smketterer
Copy link

Hello, firstly, thank you for your work on this project! I found this project somewhat randomly, searching on Github, so please bear with me.

I'm running into an issue when I started serving my images through S3, that hopefully has an easy fix.

Uncaught (in promise) DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
    at parseStereo (https://cdn.skypack.dev/-/stereo-img@v1.2.0-SvezlHHBimxuzf5wxiFG/dist=es2019,mode=imports/optimized/stereo-img.js:84:128)
    at async HTMLElement.parse (https://cdn.skypack.dev/-/stereo-img@v1.2.0-SvezlHHBimxuzf5wxiFG/dist=es2019,mode=imports/optimized/stereo-img.js:220:25)
    at async HTMLElement.parseImageAndInitialize3DScene (https://cdn.skypack.dev/-/stereo-img@v1.2.0-SvezlHHBimxuzf5wxiFG/dist=es2019,mode=imports/optimized/stereo-img.js:275:5)
    at async HTMLElement.init (https://cdn.skypack.dev/-/stereo-img@v1.2.0-SvezlHHBimxuzf5wxiFG/dist=es2019,mode=imports/optimized/stereo-img.js:292:5)

I poked around a little bit, and apparently you can set an option to allow anonymous cross-origin on the canvas image: https://stackoverflow.com/questions/22097747/how-to-fix-getimagedata-error-the-canvas-has-been-tainted-by-cross-origin-data

Setting the headers as outlined in the answer there is easy to do on my end.

Perhaps there are alternative solutions as well?

Thanks for taking a look.

@steren
Copy link
Owner

steren commented Jan 12, 2022

Thanks for reporting. I hadn't try to load an image from a different domain. It's be great to support that since that something regular support.

I will take a closer look, but it seems the server needs to allow CORS and the code might need to be updated with image.crossOrigin = 'anonymous';

@steren steren closed this as completed in c0f0194 Jan 14, 2022
steren added a commit that referenced this issue Jan 30, 2022
It was breaking the library.

#14
@steren
Copy link
Owner

steren commented Jan 31, 2022

I reverted the change because it introduced an issue I see #15

@steren steren reopened this Jan 31, 2022
@steren steren changed the title Failed to execute 'getImageData' when images are served cross-origin Support images from arbitrary origins Feb 20, 2022
@steren steren added the enhancement New feature or request label Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants