|
<!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'); |
|
} |
|
|
|
|
|
|
|
#text { |
|
position: absolute; |
|
top: 150px; |
|
transform: translateY(-50%); |
|
font-size: 2rem; |
|
z-index: 1; |
|
white-space: nowrap; |
|
|
|
font-family: 'CustomFont', Arial, sans-serif; |
|
|
|
margin: 0 auto; |
|
} |
|
|
|
|
|
.letter { |
|
transition: opacity 0.3s ease-out; |
|
} |
|
|
|
|
|
.slide-image { |
|
position: absolute; |
|
top: 150px; |
|
right: -100%; |
|
transform: translateY(-50%); |
|
animation: slide 45s linear infinite; |
|
|
|
} |
|
|
|
@keyframes slide { |
|
0% { |
|
right: -60%; |
|
} |
|
50% { |
|
right: 50%; |
|
} |
|
100% { |
|
right: 100%; |
|
} |
|
} |
|
|
|
|
|
|
|
.day-mode { |
|
background-color: #f0f0f0; |
|
color: black; |
|
} |
|
|
|
|
|
.night-mode { |
|
background-color: #2e2e2e; |
|
color: white; |
|
} |
|
|
|
|
|
.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> |
|
|
|
<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> |
|
|
|
|
|
<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> |
|
|
|
|
|
<div id="processing" class="zoom-overlay"> |
|
<p style="color:orange;">Processing... Please wait</p> |
|
<img src="erasing.gif" alt="Processing GIF"> |
|
</div> |
|
|
|
|
|
<div id="success" class="zoom-overlay" style="color:orange;"> |
|
<p>Success!</p> |
|
<img src="rbg.gif" alt="Success GIF"> |
|
|
|
</div> |
|
<br> |
|
<br> |
|
<br> |
|
<br> |
|
|
|
|
|
<div class="grid-container" id="grid-container"> |
|
|
|
</div> |
|
</div> |
|
|
|
|
|
<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(); |
|
const imageElement = document.querySelector('.slide-image'); |
|
const fadeOutDuration = 25 * 1000; |
|
const baseDelay = 1000; |
|
|
|
|
|
function fadeOutLetters() { |
|
letters.forEach((letter, index) => { |
|
setTimeout(() => { |
|
letter.style.opacity = 0; |
|
}, baseDelay * index); |
|
}); |
|
} |
|
|
|
|
|
function resetLetters() { |
|
letters.forEach((letter) => { |
|
letter.style.opacity = 1; |
|
}); |
|
} |
|
|
|
|
|
imageElement.addEventListener('animationiteration', () => { |
|
resetLetters(); |
|
setTimeout(fadeOutLetters, 1000); |
|
}); |
|
|
|
|
|
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; |
|
} |
|
|
|
|
|
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); |
|
|
|
|
|
processingDiv.style.display = 'none'; |
|
successDiv.style.display = 'block'; |
|
|
|
|
|
const successImage = successDiv.querySelector('img'); |
|
successImage.addEventListener('click', () => { |
|
zoomOverlay.style.display = 'flex'; |
|
zoomImage.src = successImage.src; |
|
|
|
|
|
const downloadLink = document.getElementById('download-link'); |
|
downloadLink.href = successImage.src; |
|
}); |
|
|
|
|
|
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'; |
|
|
|
|
|
imgElement.addEventListener('click', function () { |
|
zoomOverlay.style.display = 'flex'; |
|
zoomImage.src = imgElement.src; |
|
|
|
|
|
const downloadLink = document.getElementById('download-link'); |
|
downloadLink.href = imgElement.src; |
|
}); |
|
|
|
gridItem.appendChild(imgElement); |
|
gridContainer.prepend(gridItem); |
|
|
|
|
|
downloadAllBtn.style.display = 'block'; |
|
|
|
}, 3000); |
|
|
|
} catch (error) { |
|
console.error('Error:', error); |
|
alert("An error occurred while processing the image."); |
|
} finally { |
|
processingDiv.style.display = 'none'; |
|
} |
|
}); |
|
|
|
|
|
document.querySelector('#processing img').addEventListener('click', function () { |
|
zoomOverlay.style.display = 'flex'; |
|
zoomImage.src = this.src; |
|
|
|
|
|
const downloadLink = document.getElementById('download-link'); |
|
downloadLink.href = this.src; |
|
}); |
|
|
|
|
|
document.getElementById('zoom-overlay').addEventListener('click', function (e) { |
|
if (e.target === this) { |
|
this.style.display = 'none'; |
|
} |
|
}); |
|
|
|
|
|
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++; |
|
|
|
|
|
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> |