Using fairly basic code.
HTML
<img id="img" style="max-width: 100%; max-height: 650px; " />
Javascript
var image = document.getElementById("img");
image.crossOrigin = "anonymous";
image.addEventListener('load', function (event) {
alert("here");
orgImg.width = this.naturalWidth;
orgImg.height = this.naturalHeight;
orgImg.getContext("2d").drawImage(this, 0, 0);
//etc
orgImg.getContext("2d").getImageData(0, 0, orgImg.width, orgImg.height) //security error
}, {once: true});
image.src = '<?= $this->imgSrc ?>';
imgSrc is a URL that is not on the same domain. The site is on localhost, the image is on another site, and is https.
If I remove the image.crossOrigin = "anonymous";
, the image loads, but I get the security error. If I put back the cross origin, the image doesn't load at all, the load handler is never fired.
Moving the image to the server serving the page is not a realistic option as the image would be stuck there until another service or process cleaned it out.
What did I miss?
Thanks