Skip to content

Instantly share code, notes, and snippets.

@jdmichaud
Created December 4, 2025 16:23
Show Gist options
  • Select an option

  • Save jdmichaud/303c682c1accd42656e1067ab8c889b9 to your computer and use it in GitHub Desktop.

Select an option

Save jdmichaud/303c682c1accd42656e1067ab8c889b9 to your computer and use it in GitHub Desktop.
Retrieve pixels of an image
const data = await (await fetch('Tv-test-pattern-146649_640.png')).bytes();
const decoder = new ImageDecoder({ type: "image/png", data });
const frame = await decoder.decode();
const bytes = new Uint8Array(frame.image.allocationSize());
await frame.image.copyTo(bytes.buffer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment