Spaces:
Running
Running
Update index.html
Browse files- index.html +266 -71
index.html
CHANGED
@@ -1,21 +1,3 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html lang="en">
|
3 |
-
<head>
|
4 |
-
<meta charset="UTF-8">
|
5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>Image to Prompt Generator</title>
|
7 |
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
8 |
-
<script src="https://cdn.tailwindcss.com"></script>
|
9 |
-
</head>
|
10 |
-
<body class="bg-gray-50 min-h-screen">
|
11 |
-
<!-- Header -->
|
12 |
-
<header class="text-center mb-12">
|
13 |
-
<h1 class="text-4xl font-bold text-gray-800">Image to Prompt Generator</h1>
|
14 |
-
<p class="text-gray-600 max-w-2xl mx-auto">
|
15 |
-
Upload any image and get creative AI prompts generated automatically. Perfect for artists, writers, and content creators!
|
16 |
-
</p>
|
17 |
-
</header>
|
18 |
-
|
19 |
<!-- Main Content -->
|
20 |
<div class="max-w-4xl mx-auto bg-white rounded-xl shadow-md overflow-hidden">
|
21 |
<!-- Upload Section -->
|
@@ -27,72 +9,285 @@
|
|
27 |
</div>
|
28 |
<h3 class="text-lg font-medium text-gray-700 mb-2">Drag & drop your image here</h3>
|
29 |
<p class="text-gray-500 mb-4">or click to browse files</p>
|
30 |
-
<input type="file" id="fileInput" accept="image/*">
|
31 |
<button id="uploadBtn" class="bg-blue-500 hover:bg-blue-600 text-white px-6 py-2 rounded-lg transition">
|
32 |
Select Image
|
33 |
</button>
|
34 |
</div>
|
35 |
</div>
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
</div>
|
44 |
</div>
|
|
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
</div>
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
<!-- Prompts will be inserted here by JavaScript -->
|
57 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
<
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
</div>
|
76 |
-
<
|
77 |
-
<p class="text-gray-600">Our advanced AI analyzes the visual elements, composition, and style of your image.</p>
|
78 |
</div>
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
</
|
84 |
-
<h3 class="text-lg font-medium text-gray-800 mb-2">Get Prompts</h3>
|
85 |
-
<p class="text-gray-600">Receive multiple creative prompts tailored to your image's content and your selected style.</p>
|
86 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<!-- Main Content -->
|
2 |
<div class="max-w-4xl mx-auto bg-white rounded-xl shadow-md overflow-hidden">
|
3 |
<!-- Upload Section -->
|
|
|
9 |
</div>
|
10 |
<h3 class="text-lg font-medium text-gray-700 mb-2">Drag & drop your image here</h3>
|
11 |
<p class="text-gray-500 mb-4">or click to browse files</p>
|
12 |
+
<input type="file" id="fileInput" class="hidden" accept="image/*">
|
13 |
<button id="uploadBtn" class="bg-blue-500 hover:bg-blue-600 text-white px-6 py-2 rounded-lg transition">
|
14 |
Select Image
|
15 |
</button>
|
16 |
</div>
|
17 |
</div>
|
18 |
+
<div id="imagePreviewContainer" class="mt-6 hidden">
|
19 |
+
<h3 class="text-lg font-medium text-gray-700 mb-3">Image Preview</h3>
|
20 |
+
<div class="flex flex-col md:flex-row gap-6">
|
21 |
+
<div class="w-full md:w-1/2">
|
22 |
+
<img id="imagePreview" src="#" alt="Preview" class="w-full h-auto rounded-lg border border-gray-200">
|
23 |
+
</div>
|
24 |
+
<div class="w-full md:w-1/2">
|
25 |
+
<div class="flex items-center mb-3">
|
26 |
+
<h4 class="text-md font-medium text-gray-700">Prompt Style</h4>
|
27 |
+
<div class="ml-auto relative">
|
28 |
+
<select id="styleSelect" class="appearance-none bg-gray-100 border border-gray-200 rounded-md px-4 py-2 pr-8 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
|
29 |
+
<option value="creative">Creative</option>
|
30 |
+
<option value="detailed">Detailed</option>
|
31 |
+
<option value="minimal">Minimal</option>
|
32 |
+
<option value="artistic">Artistic</option>
|
33 |
+
<option value="technical">Technical</option>
|
34 |
+
</select>
|
35 |
+
<div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
|
36 |
+
<i class="fas fa-chevron-down text-sm"></i>
|
37 |
+
</div>
|
38 |
+
</div>
|
39 |
+
</div>
|
40 |
+
<button id="generateBtn" class="w-full bg-blue-500 hover:bg-blue-600 text-white px-6 py-3 rounded-lg transition flex items-center justify-center">
|
41 |
+
<span>Generate Prompts</span>
|
42 |
+
<i id="generateIcon" class="fas fa-magic ml-2"></i>
|
43 |
+
</button>
|
44 |
+
</div>
|
45 |
</div>
|
46 |
</div>
|
47 |
+
</div>
|
48 |
|
49 |
+
<!-- Loading State -->
|
50 |
+
<div id="loadingState" class="p-8 hidden">
|
51 |
+
<div class="flex flex-col items-center justify-center py-12">
|
52 |
+
<div class="w-16 h-16 border-4 border-blue-500 border-t-transparent rounded-full loading-spinner mb-4"></div>
|
53 |
+
<h3 class="text-lg font-medium text-gray-700 mb-2">Analyzing your image</h3>
|
54 |
+
<p class="text-gray-500">This may take a few moments...</p>
|
55 |
+
</div>
|
56 |
+
</div>
|
|
|
57 |
|
58 |
+
<!-- Results Section -->
|
59 |
+
<div id="resultsSection" class="p-8 hidden">
|
60 |
+
<div class="flex items-center justify-between mb-6">
|
61 |
+
<h2 class="text-xl font-bold text-gray-800">Generated Prompts</h2>
|
62 |
+
<button id="copyAllBtn" class="text-sm bg-gray-100 hover:bg-gray-200 text-gray-700 px-4 py-2 rounded-md transition flex items-center">
|
63 |
+
<i class="fas fa-copy mr-2"></i>
|
64 |
+
Copy All
|
65 |
+
</button>
|
66 |
+
</div>
|
67 |
+
|
68 |
+
<div id="promptsContainer" class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
69 |
<!-- Prompts will be inserted here by JavaScript -->
|
70 |
</div>
|
71 |
+
|
72 |
+
<div class="mt-8 pt-6 border-t border-gray-200">
|
73 |
+
<h3 class="text-lg font-medium text-gray-700 mb-4">Try another image</h3>
|
74 |
+
<button id="newImageBtn" class="bg-gray-100 hover:bg-gray-200 text-gray-700 px-6 py-2 rounded-lg transition">
|
75 |
+
<i class="fas fa-redo mr-2"></i>
|
76 |
+
Start Over
|
77 |
+
</button>
|
78 |
+
</div>
|
79 |
+
</div>
|
80 |
+
</div>
|
81 |
|
82 |
+
<!-- Features Section -->
|
83 |
+
<div class="max-w-4xl mx-auto mt-16">
|
84 |
+
<h2 class="text-2xl font-bold text-gray-800 mb-8 text-center">How It Works</h2>
|
85 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
|
86 |
+
<div class="bg-white p-6 rounded-xl shadow-sm">
|
87 |
+
<div class="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center mb-4">
|
88 |
+
<i class="fas fa-upload text-blue-500"></i>
|
89 |
+
</div>
|
90 |
+
<h3 class="text-lg font-medium text-gray-800 mb-2">Upload Image</h3>
|
91 |
+
<p class="text-gray-600">Drag & drop or select any image from your device. We support JPG, PNG, and WEBP formats.</p>
|
92 |
+
</div>
|
93 |
+
<div class="bg-white p-6 rounded-xl shadow-sm">
|
94 |
+
<div class="w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center mb-4">
|
95 |
+
<i class="fas fa-brain text-purple-500"></i>
|
96 |
+
</div>
|
97 |
+
<h3 class="text-lg font-medium text-gray-800 mb-2">AI Analysis</h3>
|
98 |
+
<p class="text-gray-600">Our advanced AI analyzes the visual elements, composition, and style of your image.</p>
|
99 |
+
</div>
|
100 |
+
<div class="bg-white p-6 rounded-xl shadow-sm">
|
101 |
+
<div class="w-12 h-12 bg-green-100 rounded-full flex items-center justify-center mb-4">
|
102 |
+
<i class="fas fa-lightbulb text-green-500"></i>
|
103 |
+
</div>
|
104 |
+
<h3 class="text-lg font-medium text-gray-800 mb-2">Get Prompts</h3>
|
105 |
+
<p class="text-gray-600">Receive multiple creative prompts tailored to your image's content and your selected style.</p>
|
106 |
+
</div>
|
107 |
+
</div>
|
108 |
+
</div>
|
109 |
+
</div>
|
110 |
+
|
111 |
+
<script>
|
112 |
+
document.addEventListener('DOMContentLoaded', function() {
|
113 |
+
// DOM Elements
|
114 |
+
const dropzone = document.getElementById('dropzone');
|
115 |
+
const fileInput = document.getElementById('fileInput');
|
116 |
+
const uploadBtn = document.getElementById('uploadBtn');
|
117 |
+
const imagePreviewContainer = document.getElementById('imagePreviewContainer');
|
118 |
+
const imagePreview = document.getElementById('imagePreview');
|
119 |
+
const generateBtn = document.getElementById('generateBtn');
|
120 |
+
const loadingState = document.getElementById('loadingState');
|
121 |
+
const resultsSection = document.getElementById('resultsSection');
|
122 |
+
const promptsContainer = document.getElementById('promptsContainer');
|
123 |
+
const copyAllBtn = document.getElementById('copyAllBtn');
|
124 |
+
const newImageBtn = document.getElementById('newImageBtn');
|
125 |
+
const styleSelect = document.getElementById('styleSelect');
|
126 |
+
const generateIcon = document.getElementById('generateIcon');
|
127 |
+
|
128 |
+
// Event Listeners
|
129 |
+
uploadBtn.addEventListener('click', () => fileInput.click());
|
130 |
+
fileInput.addEventListener('change', handleFileSelect);
|
131 |
+
dropzone.addEventListener('dragover', handleDragOver);
|
132 |
+
dropzone.addEventListener('dragleave', handleDragLeave);
|
133 |
+
dropzone.addEventListener('drop', handleDrop);
|
134 |
+
generateBtn.addEventListener('click', generatePrompts);
|
135 |
+
copyAllBtn.addEventListener('click', copyAllPrompts);
|
136 |
+
newImageBtn.addEventListener('click', resetForm);
|
137 |
+
|
138 |
+
// Functions
|
139 |
+
function handleFileSelect(e) {
|
140 |
+
const file = e.target.files[0];
|
141 |
+
if (file && file.type.match('image.*')) {
|
142 |
+
displayImagePreview(file);
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
function handleDragOver(e) {
|
147 |
+
e.preventDefault();
|
148 |
+
dropzone.classList.add('active');
|
149 |
+
}
|
150 |
+
|
151 |
+
function handleDragLeave() {
|
152 |
+
dropzone.classList.remove('active');
|
153 |
+
}
|
154 |
+
|
155 |
+
function handleDrop(e) {
|
156 |
+
e.preventDefault();
|
157 |
+
dropzone.classList.remove('active');
|
158 |
+
|
159 |
+
const file = e.dataTransfer.files[0];
|
160 |
+
if (file && file.type.match('image.*')) {
|
161 |
+
displayImagePreview(file);
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
function displayImagePreview(file) {
|
166 |
+
const reader = new FileReader();
|
167 |
+
reader.onload = function(e) {
|
168 |
+
imagePreview.src = e.target.result;
|
169 |
+
imagePreviewContainer.classList.remove('hidden');
|
170 |
+
dropzone.classList.add('hidden');
|
171 |
+
};
|
172 |
+
reader.readAsDataURL(file);
|
173 |
+
}
|
174 |
+
|
175 |
+
function generatePrompts() {
|
176 |
+
// Show loading state
|
177 |
+
imagePreviewContainer.classList.add('hidden');
|
178 |
+
loadingState.classList.remove('hidden');
|
179 |
+
generateIcon.classList.replace('fa-magic', 'fa-spinner');
|
180 |
+
generateIcon.classList.add('loading-spinner');
|
181 |
+
|
182 |
+
// Simulate API call with timeout
|
183 |
+
setTimeout(() => {
|
184 |
+
loadingState.classList.add('hidden');
|
185 |
+
resultsSection.classList.remove('hidden');
|
186 |
+
displayGeneratedPrompts();
|
187 |
+
}, 2500);
|
188 |
+
}
|
189 |
+
|
190 |
+
function displayGeneratedPrompts() {
|
191 |
+
// Clear previous prompts
|
192 |
+
promptsContainer.innerHTML = '';
|
193 |
+
|
194 |
+
// Get selected style
|
195 |
+
const style = styleSelect.value;
|
196 |
+
|
197 |
+
// Generate sample prompts based on style (in a real app, these would come from an API)
|
198 |
+
const samplePrompts = {
|
199 |
+
creative: [
|
200 |
+
"A surreal dreamscape where the elements of this image come alive in unexpected ways",
|
201 |
+
"Imagine this scene as part of a fantasy world with magical enhancements",
|
202 |
+
"Reinterpret this composition in the style of a famous artist's painting"
|
203 |
+
],
|
204 |
+
detailed: [
|
205 |
+
"A highly detailed description of all visual elements including colors, textures, lighting, and spatial relationships",
|
206 |
+
"Break down the composition into its fundamental elements with precise terminology",
|
207 |
+
"Technical analysis of the image's color palette, contrast, and focal points"
|
208 |
+
],
|
209 |
+
minimal: [
|
210 |
+
"Simple, clean interpretation focusing only on essential elements",
|
211 |
+
"Reduced to basic shapes and colors while maintaining recognizability",
|
212 |
+
"Minimalist version emphasizing negative space and simplicity"
|
213 |
+
],
|
214 |
+
artistic: [
|
215 |
+
"Artistic interpretation with emphasis on brush strokes and painterly qualities",
|
216 |
+
"Describe how to recreate this image using traditional art techniques",
|
217 |
+
"Analysis of the artistic style and potential influences"
|
218 |
+
],
|
219 |
+
technical: [
|
220 |
+
"Technical specifications for recreating this image in digital art software",
|
221 |
+
"Detailed breakdown of camera settings if this were a photograph",
|
222 |
+
"Color theory analysis with hex codes for major color areas"
|
223 |
+
]
|
224 |
+
};
|
225 |
+
|
226 |
+
// Create prompt cards
|
227 |
+
samplePrompts[style].forEach((prompt, index) => {
|
228 |
+
const promptCard = document.createElement('div');
|
229 |
+
promptCard.className = 'prompt-card bg-white border border-gray-200 rounded-lg p-4 hover:shadow-md cursor-pointer';
|
230 |
+
promptCard.innerHTML = `
|
231 |
+
<div class="flex items-start mb-3">
|
232 |
+
<div class="w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center flex-shrink-0 mr-3">
|
233 |
+
<span class="text-blue-500 font-medium">${index + 1}</span>
|
234 |
</div>
|
235 |
+
<p class="text-gray-700 flex-grow">${prompt}</p>
|
|
|
236 |
</div>
|
237 |
+
<div class="flex justify-end">
|
238 |
+
<button class="copy-prompt-btn text-sm text-gray-500 hover:text-blue-500 transition">
|
239 |
+
<i class="fas fa-copy mr-1"></i>
|
240 |
+
Copy
|
241 |
+
</button>
|
|
|
|
|
242 |
</div>
|
243 |
+
`;
|
244 |
+
promptsContainer.appendChild(promptCard);
|
245 |
+
|
246 |
+
// Add click event to copy button
|
247 |
+
const copyBtn = promptCard.querySelector('.copy-prompt-btn');
|
248 |
+
copyBtn.addEventListener('click', (e) => {
|
249 |
+
e.stopPropagation();
|
250 |
+
navigator.clipboard.writeText(prompt);
|
251 |
+
|
252 |
+
// Show feedback
|
253 |
+
const originalText = copyBtn.innerHTML;
|
254 |
+
copyBtn.innerHTML = '<i class="fas fa-check mr-1"></i> Copied!';
|
255 |
+
setTimeout(() => {
|
256 |
+
copyBtn.innerHTML = originalText;
|
257 |
+
}, 2000);
|
258 |
+
});
|
259 |
+
|
260 |
+
// Add click event to select prompt
|
261 |
+
promptCard.addEventListener('click', () => {
|
262 |
+
navigator.clipboard.writeText(prompt);
|
263 |
+
promptCard.classList.add('border-blue-500', 'bg-blue-50');
|
264 |
+
setTimeout(() => {
|
265 |
+
promptCard.classList.remove('border-blue-500', 'bg-blue-50');
|
266 |
+
}, 1000);
|
267 |
+
});
|
268 |
+
});
|
269 |
+
}
|
270 |
+
|
271 |
+
function copyAllPrompts() {
|
272 |
+
const prompts = Array.from(document.querySelectorAll('.prompt-card p')).map(p => p.textContent);
|
273 |
+
navigator.clipboard.writeText(prompts.join('\n\n'));
|
274 |
+
|
275 |
+
// Show feedback
|
276 |
+
const originalText = copyAllBtn.innerHTML;
|
277 |
+
copyAllBtn.innerHTML = '<i class="fas fa-check mr-2"></i> All Copied!';
|
278 |
+
setTimeout(() => {
|
279 |
+
copyAllBtn.innerHTML = originalText;
|
280 |
+
}, 2000);
|
281 |
+
}
|
282 |
|
283 |
+
function resetForm() {
|
284 |
+
fileInput.value = '';
|
285 |
+
imagePreview.src = '#';
|
286 |
+
resultsSection.classList.add('hidden');
|
287 |
+
imagePreviewContainer.classList.add('hidden');
|
288 |
+
dropzone.classList.remove('hidden');
|
289 |
+
generateIcon.classList.replace('fa-spinner', 'fa-magic');
|
290 |
+
generateIcon.classList.remove('loading-spinner');
|
291 |
+
}
|
292 |
+
});
|
293 |
+
</script>
|