image-generator / index.html
Fazle55's picture
Image Generator - Initial Deployment
67188a7 verified
Raw
History Blame Contribute Delete
17.1 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PixelCraft - AI Image Generator</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.gradient-bg {
background: linear-gradient(135deg, #6e8efb, #a777e3);
}
.image-card {
transition: all 0.3s ease;
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
.image-card:hover {
transform: translateY(-5px);
box-shadow: 0 15px 30px rgba(0,0,0,0.2);
}
.loading-spinner {
border: 4px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top: 4px solid white;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.prompt-input:focus {
outline: none;
box-shadow: 0 0 0 3px rgba(167, 119, 227, 0.3);
}
</style>
</head>
<body class="min-h-screen bg-gray-100">
<div class="gradient-bg text-white">
<div class="container mx-auto px-4 py-8">
<header class="flex flex-col md:flex-row justify-between items-center mb-8">
<div class="flex items-center mb-4 md:mb-0">
<i class="fas fa-palette text-3xl mr-3"></i>
<h1 class="text-3xl font-bold">PixelCraft</h1>
</div>
<nav class="flex space-x-6">
<a href="#" class="hover:text-gray-200 transition">Home</a>
<a href="#" class="hover:text-gray-200 transition">Gallery</a>
<a href="#" class="hover:text-gray-200 transition">About</a>
<a href="#" class="hover:text-gray-200 transition">Contact</a>
</nav>
</header>
<div class="text-center py-12">
<h2 class="text-4xl md:text-5xl font-bold mb-6">Create Stunning AI Art</h2>
<p class="text-xl mb-8 max-w-2xl mx-auto">Transform your imagination into beautiful images with our powerful AI generator</p>
<div class="max-w-3xl mx-auto bg-white rounded-lg shadow-xl overflow-hidden">
<div class="p-6">
<div class="flex flex-col md:flex-row gap-4">
<input type="text" id="prompt" placeholder="Describe the image you want to create..."
class="prompt-input flex-grow px-4 py-3 rounded-lg border border-gray-300 focus:border-purple-500 text-gray-800">
<button id="generate-btn" class="bg-purple-600 hover:bg-purple-700 text-white px-6 py-3 rounded-lg font-medium transition flex items-center justify-center">
<i class="fas fa-magic mr-2"></i> Generate
</button>
</div>
<div class="mt-4 flex flex-wrap gap-2">
<button class="style-btn px-3 py-1 bg-gray-200 text-gray-800 rounded-full text-sm hover:bg-gray-300 transition" data-style="digital art">Digital Art</button>
<button class="style-btn px-3 py-1 bg-gray-200 text-gray-800 rounded-full text-sm hover:bg-gray-300 transition" data-style="photorealistic">Photorealistic</button>
<button class="style-btn px-3 py-1 bg-gray-200 text-gray-800 rounded-full text-sm hover:bg-gray-300 transition" data-style="fantasy">Fantasy</button>
<button class="style-btn px-3 py-1 bg-gray-200 text-gray-800 rounded-full text-sm hover:bg-gray-300 transition" data-style="anime">Anime</button>
<button class="style-btn px-3 py-1 bg-gray-200 text-gray-800 rounded-full text-sm hover:bg-gray-300 transition" data-style="watercolor">Watercolor</button>
</div>
</div>
</div>
</div>
</div>
</div>
<main class="container mx-auto px-4 py-12">
<div class="flex justify-between items-center mb-8">
<h3 class="text-2xl font-bold text-gray-800">Your Creations</h3>
<div class="flex items-center space-x-2">
<span class="text-gray-600">Style:</span>
<select id="filter-style" class="px-3 py-1 border rounded-lg bg-white">
<option value="all">All Styles</option>
<option value="digital art">Digital Art</option>
<option value="photorealistic">Photorealistic</option>
<option value="fantasy">Fantasy</option>
<option value="anime">Anime</option>
<option value="watercolor">Watercolor</option>
</select>
</div>
</div>
<div id="loading" class="hidden flex-col items-center justify-center py-12">
<div class="loading-spinner mb-4"></div>
<p class="text-gray-600">Generating your masterpiece...</p>
</div>
<div id="image-grid" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
<!-- Sample images -->
<div class="image-card bg-white rounded-xl overflow-hidden" data-style="fantasy">
<img src="https://source.unsplash.com/random/600x600/?fantasy,castle" alt="Fantasy castle" class="w-full h-64 object-cover">
<div class="p-4">
<p class="text-gray-600 text-sm mb-2">Fantasy style</p>
<p class="font-medium">Mystical castle in the clouds</p>
<div class="flex justify-between items-center mt-4">
<button class="text-purple-600 hover:text-purple-800 transition">
<i class="fas fa-download mr-1"></i> Download
</button>
<button class="text-gray-500 hover:text-gray-700 transition">
<i class="fas fa-share-alt"></i>
</button>
</div>
</div>
</div>
<div class="image-card bg-white rounded-xl overflow-hidden" data-style="photorealistic">
<img src="https://source.unsplash.com/random/600x600/?portrait" alt="Portrait" class="w-full h-64 object-cover">
<div class="p-4">
<p class="text-gray-600 text-sm mb-2">Photorealistic style</p>
<p class="font-medium">Professional portrait photography</p>
<div class="flex justify-between items-center mt-4">
<button class="text-purple-600 hover:text-purple-800 transition">
<i class="fas fa-download mr-1"></i> Download
</button>
<button class="text-gray-500 hover:text-gray-700 transition">
<i class="fas fa-share-alt"></i>
</button>
</div>
</div>
</div>
<div class="image-card bg-white rounded-xl overflow-hidden" data-style="anime">
<img src="https://source.unsplash.com/random/600x600/?anime" alt="Anime character" class="w-full h-64 object-cover">
<div class="p-4">
<p class="text-gray-600 text-sm mb-2">Anime style</p>
<p class="font-medium">Cute anime character with blue hair</p>
<div class="flex justify-between items-center mt-4">
<button class="text-purple-600 hover:text-purple-800 transition">
<i class="fas fa-download mr-1"></i> Download
</button>
<button class="text-gray-500 hover:text-gray-700 transition">
<i class="fas fa-share-alt"></i>
</button>
</div>
</div>
</div>
</div>
<div id="empty-state" class="hidden text-center py-16">
<i class="fas fa-image text-5xl text-gray-300 mb-4"></i>
<h4 class="text-xl font-medium text-gray-500 mb-2">No images yet</h4>
<p class="text-gray-400">Generate your first AI artwork by entering a prompt above</p>
</div>
</main>
<footer class="bg-gray-800 text-white py-8">
<div class="container mx-auto px-4">
<div class="flex flex-col md:flex-row justify-between items-center">
<div class="mb-4 md:mb-0">
<div class="flex items-center">
<i class="fas fa-palette text-2xl mr-2"></i>
<span class="text-xl font-bold">PixelCraft</span>
</div>
<p class="text-gray-400 mt-2">Create art with AI</p>
</div>
<div class="flex space-x-6">
<a href="#" class="text-gray-400 hover:text-white transition"><i class="fab fa-twitter"></i></a>
<a href="#" class="text-gray-400 hover:text-white transition"><i class="fab fa-instagram"></i></a>
<a href="#" class="text-gray-400 hover:text-white transition"><i class="fab fa-discord"></i></a>
<a href="#" class="text-gray-400 hover:text-white transition"><i class="fab fa-github"></i></a>
</div>
</div>
<div class="border-t border-gray-700 mt-8 pt-8 text-center text-gray-400">
<p>&copy; 2023 PixelCraft. All rights reserved.</p>
</div>
</div>
</footer>
<script>
document.addEventListener('DOMContentLoaded', function() {
const generateBtn = document.getElementById('generate-btn');
const promptInput = document.getElementById('prompt');
const imageGrid = document.getElementById('image-grid');
const loading = document.getElementById('loading');
const emptyState = document.getElementById('empty-state');
const styleBtns = document.querySelectorAll('.style-btn');
const filterStyle = document.getElementById('filter-style');
let currentStyle = 'digital art';
// Check if there are any images and show empty state if not
function checkEmptyState() {
const images = imageGrid.querySelectorAll('.image-card');
if (images.length === 0) {
emptyState.classList.remove('hidden');
imageGrid.classList.add('hidden');
} else {
emptyState.classList.add('hidden');
imageGrid.classList.remove('hidden');
}
}
// Set style from buttons
styleBtns.forEach(btn => {
btn.addEventListener('click', function() {
currentStyle = this.dataset.style;
styleBtns.forEach(b => b.classList.remove('bg-purple-100', 'text-purple-800'));
this.classList.add('bg-purple-100', 'text-purple-800');
});
});
// Filter images by style
filterStyle.addEventListener('change', function() {
const selectedStyle = this.value;
const images = imageGrid.querySelectorAll('.image-card');
images.forEach(img => {
if (selectedStyle === 'all' || img.dataset.style === selectedStyle) {
img.classList.remove('hidden');
} else {
img.classList.add('hidden');
}
});
checkEmptyState();
});
// Generate new image
generateBtn.addEventListener('click', function() {
const prompt = promptInput.value.trim();
if (prompt === '') {
alert('Please enter a description for your image');
return;
}
// Show loading state
loading.classList.remove('hidden');
imageGrid.classList.add('hidden');
// Simulate API call with timeout
setTimeout(() => {
// Create new image card
const newImage = document.createElement('div');
newImage.className = 'image-card bg-white rounded-xl overflow-hidden';
newImage.dataset.style = currentStyle;
// Random image from unsplash based on prompt and style
const randomId = Math.floor(Math.random() * 1000);
const imgUrl = `https://source.unsplash.com/random/600x600/?${encodeURIComponent(prompt)},${currentStyle}&${randomId}`;
newImage.innerHTML = `
<img src="${imgUrl}" alt="${prompt}" class="w-full h-64 object-cover">
<div class="p-4">
<p class="text-gray-600 text-sm mb-2">${currentStyle.charAt(0).toUpperCase() + currentStyle.slice(1)} style</p>
<p class="font-medium">${prompt}</p>
<div class="flex justify-between items-center mt-4">
<button class="download-btn text-purple-600 hover:text-purple-800 transition">
<i class="fas fa-download mr-1"></i> Download
</button>
<button class="text-gray-500 hover:text-gray-700 transition">
<i class="fas fa-share-alt"></i>
</button>
</div>
</div>
`;
// Add to the beginning of the grid
imageGrid.insertBefore(newImage, imageGrid.firstChild);
// Add download functionality
newImage.querySelector('.download-btn').addEventListener('click', function() {
const link = document.createElement('a');
link.href = imgUrl;
link.download = `pixelcraft-${prompt.toLowerCase().replace(/\s+/g, '-')}.jpg`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});
// Hide loading and show grid
loading.classList.add('hidden');
imageGrid.classList.remove('hidden');
emptyState.classList.add('hidden');
// Clear input
promptInput.value = '';
}, 2000);
});
// Initialize download buttons for sample images
document.querySelectorAll('.download-btn').forEach(btn => {
btn.addEventListener('click', function() {
const imgUrl = this.closest('.image-card').querySelector('img').src;
const prompt = this.closest('.image-card').querySelector('.font-medium').textContent;
const link = document.createElement('a');
link.href = imgUrl;
link.download = `pixelcraft-${prompt.toLowerCase().replace(/\s+/g, '-')}.jpg`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});
});
// Check initial empty state
checkEmptyState();
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Fazle55/image-generator" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>