Initial upload
This commit is contained in:
commit
8d953e1252
13 changed files with 7521 additions and 0 deletions
30
public/main.js
Normal file
30
public/main.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
async function init() {
|
||||
let rustApp = null
|
||||
|
||||
try {
|
||||
rustApp = await import("../pkg")
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return
|
||||
}
|
||||
|
||||
console.log(rustApp)
|
||||
|
||||
const input = document.getElementById("upload")
|
||||
const fileReader = new FileReader()
|
||||
|
||||
fileReader.onloadend = () => {
|
||||
const base64 = fileReader.result.replace(
|
||||
/^data:image\/(png|jpeg|jpg);base64,/,
|
||||
""
|
||||
)
|
||||
let img_data_url = rustApp.grayscale(base64)
|
||||
document.getElementById("new-img").setAttribute("src", img_data_url)
|
||||
}
|
||||
|
||||
input.addEventListener("change", () => {
|
||||
fileReader.readAsDataURL(input.files[0])
|
||||
})
|
||||
}
|
||||
|
||||
init()
|
||||
Loading…
Add table
Add a link
Reference in a new issue