-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
252 lines (226 loc) · 7.76 KB
/
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Background Remover</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Poppins', sans-serif;
background: linear-gradient(to bottom right, #eef2f3, #8e9eab);
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
overflow: hidden;
}
.container {
background-color: #ffffff;
padding: 40px;
border-radius: 20px;
box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
text-align: center;
max-width: 600px;
width: 90%;
animation: fadeIn 0.5s ease-in-out;
position: relative;
}
h1 {
color: #333333;
margin-bottom: 30px;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
font-size: 36px;
background: linear-gradient(to right, #4CAF50, #008CBA);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
}
input[type="file"] {
display: none;
}
.file-upload {
background-color: #4CAF50;
color: #ffffff;
padding: 12px 24px;
border-radius: 30px;
cursor: pointer;
margin-bottom: 10px;
transition: background-color 0.3s ease;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
font-size: 16px;
position: relative;
overflow: hidden;
}
.file-upload:hover {
background-color: #45a049;
}
.file-name {
margin-bottom: 20px;
color: #666666;
}
button[type="submit"] {
background-color: #008CBA;
color: #ffffff;
padding: 12px 24px;
border: none;
border-radius: 30px;
cursor: pointer;
transition: background-color 0.3s ease;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
font-size: 16px;
position: relative;
}
button[type="submit"]:hover {
background-color: #0077a3;
}
button[type="submit"]::after,
.file-upload::after {
content: attr(data-tooltip);
position: absolute;
bottom: -24px;
left: 50%;
transform: translateX(-50%);
background-color: rgba(0, 0, 0, 0.8);
color: #ffffff;
padding: 4px 8px;
border-radius: 4px;
font-size: 12px;
opacity: 0;
transition: opacity 0.3s ease;
white-space: nowrap;
}
button[type="submit"]:hover::after,
.file-upload:hover::after {
opacity: 1;
}
.image-container {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 20px;
margin-top: 20px;
animation: fadeIn 0.5s ease-in-out;
}
.image-container img {
max-width: 45%;
max-height: 300px;
border-radius: 10px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease, opacity 0.3s ease;
opacity: 0;
}
.image-container img.show {
opacity: 1;
}
.image-container img:hover {
transform: scale(1.05);
}
.spinner {
display: none;
width: 40px;
height: 40px;
border: 4px solid rgba(0, 0, 0, 0.1);
border-radius: 50%;
border-top-color: #008CBA;
animation: spin 1s linear infinite;
margin: 20px auto;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* Additional styles */
.container::before {
content: "";
position: absolute;
top: -10px;
left: -10px;
right: -10px;
bottom: -10px;
background: linear-gradient(to right, #eef2f3, #8e9eab);
z-index: -1;
border-radius: 30px;
box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
animation: rotate 10s linear infinite;
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
/* Background particles */
body::before {
content: "";
position: absolute;
width: 100%;
height: 100%;
background: url('https://www.transparenttextures.com/patterns/dust.png') repeat;
z-index: -2;
opacity: 0.2;
pointer-events: none;
}
</style>
</head>
<body>
<div class="container">
<h1>Background Remover</h1>
<form action="/remove_background" method="post" enctype="multipart/form-data" aria-label="Upload Image Form">
<label class="file-upload" data-tooltip="Upload your image file" aria-label="Choose an image file">
Choose an image
<input type="file" name="file" required aria-required="true">
</label><br><br>
<div class="file-name" id="file-name">No file chosen</div>
<button type="submit" data-tooltip="Start processing" aria-label="Remove Background Button">Remove Background</button>
</form>
<div class="spinner" id="spinner" aria-label="Loading Spinner"></div>
<div class="image-container">
<img id="original-image" alt="Original Image">
<img id="processed-image" alt="Processed Image">
</div>
</div>
<script>
const form = document.querySelector('form');
const originalImageElement = document.getElementById('original-image');
const processedImageElement = document.getElementById('processed-image');
const spinner = document.getElementById('spinner');
const fileNameDisplay = document.getElementById('file-name');
const fileInput = document.querySelector('input[type="file"]');
fileInput.addEventListener('change', (event) => {
const fileName = event.target.files[0] ? event.target.files[0].name : 'No file chosen';
fileNameDisplay.textContent = fileName;
});
form.addEventListener('submit', async (event) => {
event.preventDefault();
spinner.style.display = 'block';
const formData = new FormData(event.target);
const response = await fetch('/remove_background', {
method: 'POST',
body: formData
});
const blob = await response.blob();
const originalFileName = response.headers.get('Content-Disposition').split('=')[1];
originalImageElement.src = URL.createObjectURL(formData.get('file'));
processedImageElement.src = URL.createObjectURL(blob);
spinner.style.display = 'none';
originalImageElement.classList.add('show');
processedImageElement.classList.add('show');
});
</script>
</body>
</html>