let base64Image = "";
document.getElementById("imageInput").addEventListener("change", function(){ const file = this.files[0]; const reader = new FileReader(); reader.onload = function(){ base64Image = reader.result.split(',')[1]; document.getElementById("preview").src = reader.result; } reader.readAsDataURL(file); });
async function analyzeImage(){
if(!base64Image){ alert("Please upload an image first."); return; }
const style = document.getElementById("style").value;
// ЁЯФС PUT YOUR GEMINI API KEY HERE const API_KEY = "AIzaSyDEEoEyDNHyD7yb7TTYwzaYHZ81x5m1pnQ";
try{
const response = await fetch( `https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=${API_KEY}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ contents: [{ parts: [ { text: "Describe this image in detail. Identify the main subject and environment clearly." }, { inlineData: { mimeType: "image/jpeg", data: base64Image } } ] }] }) });
const data = await response.json();
if(!data.candidates){ alert("API Error. Check API key & billing."); console.log(data); return; }
const description = data.candidates[0].content.parts[0].text;
const finalPrompt = ` Ultra hyper-detailed ${style} image of ${description}, microscopic surface textures clearly visible, fine scratches, subtle imperfections, physically accurate material response, PBR textures, subsurface scattering, ray-traced reflections, global illumination, volumetric lighting, HDR, 8K ultra resolution, RAW photography quality, cinematic depth of field, razor sharp focal plane, ultra texture clarity, extreme realism. `;
document.getElementById("result").innerText = finalPrompt;
}catch(error){ alert("Something went wrong. Check console."); console.error(error); }
}
function copyPrompt(){ var text = document.getElementById("result").innerText; navigator.clipboard.writeText(text); alert("Prompt Copied!"); }





