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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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Image Background Remover</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js"></script>
      <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Playfair Display';
            text-align:center;
            background-color: #f0f0f0;
        }

 @font-face {
    font-family: 'CustomFont';
    src: url('coldnightforalligators.ttf') format('truetype');
}

        /* Wrapper for text */
  
        #text {
    position: absolute;
    top: 150px;
    transform: translateY(-50%);
    font-size: 2rem;
    z-index: 1; /* Keep text on top */
    white-space: nowrap;
    /*display: flex; /* Treat each letter as an item */
    font-family: 'CustomFont', Arial, sans-serif;
    /*text-align: center;*/
    margin: 0 auto;
}

        /* Individual letter styling */
        .letter {
            transition: opacity 0.3s ease-out; /* Smooth fade-out effect */
        }

        /* Sliding image */
        .slide-image {
            position: absolute;
            top: 150px;
            right: -100%; /* Start off-screen */
            transform: translateY(-50%);
            animation: slide 45s linear infinite; /* Infinite loop */
           
        }

        @keyframes slide {
            0% {
                right: -60%;
            }
            50% {
                right: 50%; /* Image in the center */
            }
            100% {
                right: 100%; /* Image moves off-screen to the left */
            }
        }


/* Day Mode Styles */
.day-mode {
    background-color: #f0f0f0;
    color: black;
}

/* Night Mode Styles */
.night-mode {
    background-color: #2e2e2e;
    color: white;
}

/* Night Mode button */
.night-mode-btn {
    position: fixed;
    top: 0px;
    right: 0px;
    background: linear-gradient(45deg, #ff7a7a, #ff1f5a);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 5px;
    z-index: 200;
}

.night-mode-btn:hover {
    background-color: #ff0044;
}
        .container {
            max-width: 1000px;
            margin: 0 auto;
        }

        input[type="file"] {
            display: block;
            margin: 20px auto;
        }

        button {
 
            
            color: white;
            padding: 10px 20px;
            font-size: 16px;
            cursor: pointer;
            border-radius: 5px;
            margin: 10px;
        }

        button:hover {
            background-color: #45a049;
        }

        #processing, #success {
            display: none;
            margin: auto;
        }

        .grid-container {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 20px;
            margin-top: 20px;
            padding: 10px;
        }

        .grid-item {
            position: relative;
            background: white;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 5px 15px 0 rgba(0, 0, 0, 0.1);
            transition: box-shadow 0.3s ease;
        }

        .grid-item img {
            width: 100%;
            height: auto;
            cursor: pointer;
        }

        .zoom-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: rgba(0, 0, 0, 0.7);
            z-index: 300;
            display: none;
        }

        .zoom-overlay img {
            max-height: 90%;
            max-width: 90%;
            transition: transform 0.3s ease;
        }

        .download-icon {
            position: absolute;
            top: 10px;
            right: 10px;
            background: rgba(255, 255, 255, 0.8);
            border-radius: 50%;
            padding: 10px;
            cursor: pointer;
            z-index: 400;
            transition: background 0.3s ease;
        }

        .download-icon:hover {
            background: rgba(255, 255, 255, 1);
        }
    </style>
</head>
<body>
       <button class="night-mode-btn" onclick="toggleDayNightMode()" style="position:sticky;top:0px;right:0px;">Switch to Night Mode</button>
       <div class="container">
  
     <br>
      <br>
       <br>
        <br>
   
<div id="text">
    <div>
        
         <span class="letter">I</span>
    <span class="letter">m</span>
    <span class="letter">a</span>
    <span class="letter">g</span>
    <span class="letter">e</span>
    <span>&nbsp;</span>
  
    <span class="letter">B</span>
    <span class="letter">a</span>
    <span class="letter">c</span>
    <span class="letter">k</span>
    <span class="letter">g</span>
    <span class="letter">r</span>
    <span class="letter">o</span>
    <span class="letter">u</span>
    <span class="letter">n</span>
    <span class="letter">d</span>
        
    </div>
    <!-- Each letter as a span -->
      <br>
   
   <div>
       
         <span class="letter">R</span>
    <span class="letter">e</span>
    <span class="letter">m</span>
    <span class="letter">o</span>
    <span class="letter">v</span>
    <span class="letter">e</span>
    <span class="letter">r</span>
       
   </div>
  
  
</div>

<!-- Sliding image -->
<img src="logo.gif" alt="Sliding Image" class="slide-image" style="width:200px;height:200px;">
  <br>
      <br>
       <br>
        <br>
    <br>
      <br>
       <br>
        <br>
   
        <form id="bg-remove-form">
            <label for="image" style="font-size:1.5rem;">Choose an image to remove background:</label>
            <input type="file" id="image" name="image" accept="image/*" required style="font-size:1.1rem;">
            <button type="submit" style="background: linear-gradient(45deg, 
#fbd3e9,
#bb377d);border: 2px solid #FF7171;">Remove Background</button>
        </form>
 <br>
      <br>
       <br>
        <br>
   
        <button id="download-all" style="display: none;position:sticky;right:5px;background: linear-gradient(45deg, 
#c9ffbf,
#ffafbd);border: 2px solid #90EE90;">Download All as ZIP</button>

        <!-- Processing GIF -->
        <div id="processing" class="zoom-overlay">
            <p style="color:orange;">Processing... Please wait</p>
            <img src="erasing.gif" alt="Processing GIF">
        </div>

        <!-- Success GIF -->
        <div id="success" class="zoom-overlay"  style="color:orange;">
            <p>Success!</p>
            <img src="rbg.gif" alt="Success GIF">
           
        </div>
<br>
<br>
<br>
<br>

        <!-- Grid for Processed Images -->
        <div class="grid-container" id="grid-container">
            <!-- Processed images will appear here -->
        </div>
    </div>

    <!-- Zoom Overlay -->
    <div class="zoom-overlay" id="zoom-overlay">
        <a id="download-link" download>
            <div class="download-icon">⬇️</div>
        </a>
        <img src="" alt="Zoomed Image" id="zoom-image">
    </div>
<script>

    const letters = Array.from(document.querySelectorAll('.letter')).reverse(); // Reverse letter order
    const imageElement = document.querySelector('.slide-image');
    const fadeOutDuration = 25 * 1000; // 25 seconds (matches the animation duration)
    const baseDelay = 1000; // Base delay between each letter fade (in ms)

    // Function to fade out letters sequentially
    function fadeOutLetters() {
        letters.forEach((letter, index) => {
            setTimeout(() => {
                letter.style.opacity = 0; // Fade out letter
            }, baseDelay * index);
        });
    }

    // Function to reset letters to visible
    function resetLetters() {
        letters.forEach((letter) => {
            letter.style.opacity = 1; // Reset opacity to fully visible
        });
    }

    // Handle animation iteration
    imageElement.addEventListener('animationiteration', () => {
        resetLetters(); // Ensure letters are visible for the next iteration
        setTimeout(fadeOutLetters, 1000); // Start fading after a brief delay
    });

    // Start the initial fade-out
    setTimeout(fadeOutLetters, 1000);
</script>

    <script>
    function toggleDayNightMode() {
    const body = document.body;
    const button = document.querySelector('.night-mode-btn');
    
    if (body.classList.contains('day-mode')) {
        body.classList.remove('day-mode');
        body.classList.add('night-mode');
        button.textContent = "Switch to Day Mode";
    } else {
        body.classList.remove('night-mode');
        body.classList.add('day-mode');
        button.textContent = "Switch to Night Mode";
    }
}
        document.getElementById('bg-remove-form').addEventListener('submit', async function (event) {
            event.preventDefault();

            const imageInput = document.getElementById('image');
            const processingDiv = document.getElementById('processing');
            const successDiv = document.getElementById('success');
            const gridContainer = document.getElementById('grid-container');
            const zoomOverlay = document.getElementById('zoom-overlay');
            const zoomImage = document.getElementById('zoom-image');
            const downloadAllBtn = document.getElementById('download-all');

            if (!imageInput.files.length) {
                alert("Please select an image file.");
                return;
            }

            // Show processing GIF
            processingDiv.style.display = 'block';
            successDiv.style.display = 'none';

            const formData = new FormData();
            formData.append('image', imageInput.files[0]);

            try {
                const response = await fetch('https://geek7-flk.hf.space/remove_background', {
                    method: 'POST',
                    body: formData,
                });

                if (!response.ok) {
                    const errorData = await response.json();
                    alert(`Error: ${errorData.error}`);
                    return;
                }

                const blob = await response.blob();
                const imageUrl = URL.createObjectURL(blob);

                // Hide processing and show success GIF
                processingDiv.style.display = 'none';
                successDiv.style.display = 'block';

                // Add zoom functionality to Success GIF
                const successImage = successDiv.querySelector('img');
                successImage.addEventListener('click', () => {
                    zoomOverlay.style.display = 'flex';
                    zoomImage.src = successImage.src;

                    // Update download link for the success image
                    const downloadLink = document.getElementById('download-link');
                    downloadLink.href = successImage.src;
                });

                // After 3 seconds, add image to grid
                setTimeout(() => {
                    successDiv.style.display = 'none';
                    
                    const gridItem = document.createElement('div');
                    gridItem.className = 'grid-item';

                    const imgElement = document.createElement('img');
                    imgElement.src = imageUrl;
                    imgElement.alt = 'Processed Image';

                    // Add zoom functionality to the processed image
                    imgElement.addEventListener('click', function () {
                        zoomOverlay.style.display = 'flex';
                        zoomImage.src = imgElement.src;

                        // Update download link for the processed image
                        const downloadLink = document.getElementById('download-link');
                        downloadLink.href = imgElement.src;
                    });

                    gridItem.appendChild(imgElement);
                    gridContainer.prepend(gridItem);

                    // Show the download all button if not visible
                    downloadAllBtn.style.display = 'block';

                }, 3000);
                      
            } catch (error) {
                console.error('Error:', error);
                alert("An error occurred while processing the image.");
            } finally {
                processingDiv.style.display = 'none';
            }
        });

        // Add zoom functionality to Processing GIF
        document.querySelector('#processing img').addEventListener('click', function () {
            zoomOverlay.style.display = 'flex';
            zoomImage.src = this.src;

            // Update download link for the processing image
            const downloadLink = document.getElementById('download-link');
            downloadLink.href = this.src;
        });

        // Close zoom overlay on clicking outside the zoomed image
        document.getElementById('zoom-overlay').addEventListener('click', function (e) {
            if (e.target === this) {
                this.style.display = 'none';
            }
        });

        // Download all images as a ZIP
        document.getElementById('download-all').addEventListener('click', async function () {
            const gridImages = document.querySelectorAll('.grid-item img');
            if (gridImages.length === 0) {
                alert("No images to download.");
                return;
            }

            const zip = new JSZip();
            const imgFolder = zip.folder("images");

            let count = 0;
            gridImages.forEach((img, index) => {
                fetch(img.src)
                    .then(response => response.blob())
                    .then(blob => {
                        const reader = new FileReader();
                        reader.onload = function () {
                            imgFolder.file(`image_${index + 1}.png`, reader.result.split(",")[1], { base64: true });
                            count++;

                            // Generate and download the ZIP file when all images are added
                            if (count === gridImages.length) {
                                zip.generateAsync({ type: "blob" })
                                    .then(content => {
                                        saveAs(content, "processed_images.zip");
                                    });
                            }
                        };
                        reader.readAsDataURL(blob);
                    })
                    .catch(err => console.error(`Error fetching image ${index + 1}:`, err));
            });
        });
    </script>
</body>
</html>