-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
40 lines (35 loc) · 1.31 KB
/
index.html
File metadata and controls
40 lines (35 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<html>
<head>
<meta charset="utf-8">
<script src="wasm_exec.js"></script>
<script>
// Create Go object from wasm_exec.js.
const go = new Go();
let mod, inst;
// Load our wasm binary.
WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject).then(
async result => {
mod = result.module;
inst = result.instance;
await go.run(inst);
}
);
// Function for handling uploaded images and applying transformation.
let openFile = async function(event) {
let input = event.target;
let reader = new FileReader();
reader.onload = function(){
let bytes = new Uint8Array(reader.result);
let result = processImage(bytes);
let blob = new Blob([result], {'type': 'image/jpeg'});
document.getElementById('out').src = URL.createObjectURL(blob);
};
reader.readAsArrayBuffer(input.files[0]);
};
</script>
</head>
<body>
<input type='file' accept='image/*' onchange='openFile(event)'><br>
<img id="out" />
</body>
</html>