Skip to content

Instantly share code, notes, and snippets.

@RshStone
Last active August 5, 2020 03:58
Show Gist options
  • Save RshStone/b8dd1e46f66137f813be3446defa299c to your computer and use it in GitHub Desktop.
Save RshStone/b8dd1e46f66137f813be3446defa299c to your computer and use it in GitHub Desktop.
Upload and display image
<script src = "https://www.dukelearntoprogram.com//course1/common/js/image/SimpleImage.js">
</script>
<h1>Image Practice</h1>
<canvas id = "cans"></canvas>
<p>
Filename
<input type = "file" multiple = "false" accept = "image/*" id = "input" onchange = "upload()" >
</p>
function upload(){
var fileinput = document.getElementById("input");
var canvas = document.getElementById("cans");
var img = new SimpleImage(fileinput);
img.drawTo(canvas);
}
#input{
width:225px;
font-size: 12pt;
}
canvas{
height:200px;
width:350px;
border: 1px solid lightgrey;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment