Comment by creata
1 day ago
const input = document.createElement("input");
document.body.append(input);
input.type = "file";
input.accept = "image/*";
input.onchange = e => {
if (input.files && input.files[0]) {
const canvas = document.getElementById("draw-canvas");
const ctx = canvas.getContext("2d");
createImageBitmap(input.files[0]).then(img => ctx.drawImage(img, 0, 0));
}
};
No comments yet
Contribute on Hacker News ↗