This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertImageToCanvas(image) { | |
var canvas = document.createElement("canvas"); | |
canvas.width = image.width; | |
canvas.height = image.height; | |
canvas.getContext("2d").drawImage(image, 0, 0); | |
return canvas; | |
} | |
function convertCanvasToImage(canvas) { | |
var image = new Image(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* HTML: | |
<input type="file" id="filepicker"> | |
<canvas id="outCanvas"></canvas> | |
*/ | |
filepicker.addEventListener("change", () => { | |
createImageBitmap(filepicker.files[0]) | |
.then(response => { | |
outCanvas.width = response.width; | |
outCanvas.height = response.height; |
NewerOlder