Joe-Thom
Joe-Thom

Reputation: 1

Cannot use getImageData within content.js [The Canvas has been tainted by cross-origin data]

I am creating a chrome extension that reads all images within a page and runs a deep learning model on them.

  let width = canvas.width;
  let height = canvas.height;
  let startX = (width - size) / 2;
  let startY = (height - size) / 2;
  let ctx = canvas.getContext('2d');
  let imageData = ctx.getImageData(startX, startY, size, size);

A lot of the times, I get the following error

Uncaught (in promise) DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.

Is there any other way for getting the imageData?

Upvotes: 0

Views: 48

Answers (0)

Related Questions