Skip to content
This repository has been archived by the owner on Aug 25, 2022. It is now read-only.

Not working with cross origin images #34

Open
kl0tl opened this issue May 14, 2014 · 1 comment
Open

Not working with cross origin images #34

kl0tl opened this issue May 14, 2014 · 1 comment

Comments

@kl0tl
Copy link

kl0tl commented May 14, 2014

Chrome throws:

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

As a workaround, I tried to load the images as arraybuffers to build a base64 encoded (as described here). It works well, but now Safari throws:

Cross-origin image load denied by Cross-Origin Resource Sharing policy.

The only solution I found is to remove the crossorigin attribute of the $img property of the scratchpad instance. I replaced this:

this.$img = $('<img src=""/>').attr('crossOrigin', '').css({position: 'absolute', width: '100%', height: '100%'});

with this:

this.$img = $('<img src=""/>').css({position: 'absolute', width: '100%', height: '100%'});

Is this attribute ever usefull ? It should at least be configurable.

@ShellyTan
Copy link

Thanks for your solution, @kl0tl! I was having this exact same problem. Originally tried setting crossorigin to 'anonymous,' but it still didn't work. Only once I removed the crossorigin attribute did the images finally load.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants