wScratchPad icon indicating copy to clipboard operation
wScratchPad copied to clipboard

Not working with cross origin images

Open kl0tl opened this issue 11 years ago • 1 comments

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.

kl0tl avatar May 14 '14 13:05 kl0tl

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.

ShellyTan avatar Jul 24 '14 00:07 ShellyTan