-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataToImage.html
More file actions
44 lines (41 loc) · 1 KB
/
dataToImage.html
File metadata and controls
44 lines (41 loc) · 1 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
41
42
43
44
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Image Viewer</title>
<style>
body {
margin: 0;
background: #111;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: sans-serif;
}
img {
max-width: 100%;
max-height: 100%;
}
.msg { color: white; }
</style>
</head>
<body>
<div id="app" class="msg">Loading...</div>
<script>
const params = new URLSearchParams(location.search);
const dataUrl = params.get("image");
const app = document.getElementById("app");
if (!dataUrl) {
app.textContent = "No ?image=data:image/... parameter";
} else if (!dataUrl.startsWith("data:image/")) {
app.textContent = "Invalid image format";
} else {
const img = document.createElement("img");
img.src = dataUrl;
img.onload = () => app.replaceWith(img);
img.onerror = () => app.textContent = "Failed to load image";
}
</script>
</body>
</html>