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

[Request] Allow use of the image data #55

Open
anon25519 opened this issue Jan 8, 2022 · 1 comment
Open

[Request] Allow use of the image data #55

anon25519 opened this issue Jan 8, 2022 · 1 comment

Comments

@anon25519
Copy link

It is currently impossible to use the image data due to CORS settings. To fix this, the server must be configured with the Access-Control-Allow-Origin: * header.

Sample code:

(async function f() {
  let img = new Image();
  img.crossOrigin = 'anonymous'; // allow non-authenticated downloading of the image cross-origin
  img.src = 'https://i.waifu.pics/YY~unmW.jpg'; // failed with error "CORS Missing Allow Origin"
  await img.decode();
  let bitmap = await createImageBitmap(img);
  let canvas = document.createElement('canvas');
  canvas.width = bitmap.width;
  canvas.height = bitmap.height;
  let ctx = canvas.getContext('2d');
  ctx.drawImage(bitmap, 0, 0);
  let imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
  console.log(imageData);
})();
@JSH32
Copy link
Member

JSH32 commented Apr 14, 2022

Will be done soon during rewrite, I meant to do this before but it was being funky last time.

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

No branches or pull requests

2 participants