Download image.html from Geek7/ht: direct link, hf CLI and curl.
- Browser
- Download file 15 kB
-
https://huggingface.co/spaces/Geek7/ht/resolve/main/image.html
- Command line
-
hf download hf://spaces/Geek7/ht/image.html
-
curl -L -o image.html https://huggingface.co/spaces/Geek7/ht/resolve/main/image.html
15 kB
| <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> </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> |