-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathindex.html
26 lines (23 loc) · 1001 Bytes
/
index.html
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
<html lang="en">
<head>
<title>ImageScript Example</title>
</head>
<body>
<h1>ImageScript example</h1>
<p>Simple example showing integration of ImageScript into an application (load image, modify, encode, convert to blob,
display)</p>
<p>You can find more examples on <a href="https://github.com/matmen/ImageScript/tree/master/tests">GitHub</a></p>
<img alt="ImageScript Example Result" id="image" src="https://via.placeholder.com/100x100">
<script src="https://cdn.jsdelivr.net/gh/matmen/imagescript@browser/browser/ImageScript.js"></script>
<script>
(async () => {
const avatar = await fetch('https://raw.githubusercontent.com/matmen/ImageScript/master/tests/targets/readme.png').then(r => r.arrayBuffer());
const image = await ImageScript.Image.decode(avatar);
image.saturation(0);
const encoded = await image.encode();
const blob = new Blob([encoded], {type: 'image/png'});
document.querySelector('#image').src = URL.createObjectURL(blob);
})();
</script>
</body>
</html>