8587794867133706107
  • الصفحة الرئيسية

exmpal2025

  • الرئيسية
  • قائمة الروابط
  • _إعداد قائمة
📁 آخر الأخبار جاري تحميل الأخبار...

بواسطة MOOK | يونيو 18, 2025
ض تحليل صورة باستخدام Gemini

📸 أداة توليد وصف وكلمات مفتاحية باستخدام Gemini API

📄 العنوان:

📝 الوصف:

🏷️ الكلمات المفتاحية:

لم تفهم نقطة معينة؟

اسأل المساعد الذكي وسيجيبك بناءً على محتوى هذا المقال.

ض<!--DOCTYPE html--> <html lang="ar"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>تحليل صورة باستخدام Gemini</title> <style> body { font-family: sans-serif; padding: 20px; max-width: 600px; margin: auto; } textarea { width: 100%; height: 80px; } .output { margin-top: 20px; padding: 10px; background: #f1f1f1; border-radius: 10px; } </style> </head> <body> <h2>📸 أداة توليد وصف وكلمات مفتاحية باستخدام Gemini API</h2> <input type="file" id="imageInput" accept="image/*"> <button onclick="handleUpload()">✨ تحليل الصورة</button> <div id="result" class="output" style="display: none"> <h3>📄 العنوان:</h3> <p id="title"></p> <h3>📝 الوصف:</h3> <textarea id="description" readonly></textarea> <h3>🏷️ الكلمات المفتاحية:</h3> <textarea id="keywords" readonly></textarea> </div> <script> const imgbbApiKey = "50e1e4954c051ba4fb835580690f65b7"; const geminiApiKey = "AIzaSyCCTBriQK0-_gG_Le5syt9BuViJb6W4vJA"; async function handleUpload() { const fileInput = document.getElementById("imageInput"); const file = fileInput.files[0]; if (!file) return alert("يرجى اختيار صورة أولاً."); const formData = new FormData(); formData.append("image", file); // رفع الصورة إلى imgbb للحصول على رابط مباشر const imgbbRes = await fetch(`https://api.imgbb.com/1/upload?key=${imgbbApiKey}`, { method: "POST", body: formData }); const imgbbData = await imgbbRes.json(); const imageUrl = imgbbData.data.url; // إرسال الطلب إلى Gemini const geminiRes = await fetch("https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=" + geminiApiKey, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ contents: [ { parts: [ { text: "حلل هذه الصورة وأعطني عنوانًا مناسبًا، وصفًا احترافيًا، وكلمات مفتاحية تصلح للنشر على Adobe Stock." }, { inline_data: { mime_type: file.type, data: await toBase64(file) } } ] } ] }) }); const geminiJson = await geminiRes.json(); const text = geminiJson.candidates?.[0]?.content?.parts?.[0]?.text || "لم يتم توليد نتيجة."; // استخراج العنوان والوصف والكلمات المفتاحية من النص const title = (text.match(/عنوان\s*[::]\s*(.*)/i) || [])[1] || "لا يوجد عنوان"; const desc = (text.match(/وصف\s*[::]\s*([\s\S]*?)كلمات مفتاحية/i) || [])[1] || "لا يوجد وصف"; const keywords = (text.match(/كلمات مفتاحية\s*[::]\s*(.*)/i) || [])[1] || "لا توجد كلمات مفتاحية"; document.getElementById("title").innerText = title; document.getElementById("description").value = desc.trim(); document.getElementById("keywords").value = keywords; document.getElementById("result").style.display = "block"; } function toBase64(file) { return new Promise((resolve, reject) => { const reader = new FileReader(); reader.readAsDataURL(file); reader.onload = () => resolve(reader.result.split(",")[1]); reader.onerror = error => reject(error); }); } </script> </body> </html>

شارك المقال مع أصدقائك

فيسبوك تويتر واتساب لينكدإن
Author

MOOK

تعليقات

إرسال تعليق

AIzaSyD2z2SFJdmJ3am9WNTgbE25qaCTDhKNhaE

مواقع التواصل الاجتماعي

المشاركات الشائعة

مشاركة مميزة

No Image
يونيو 18, 2025

ض تحليل صورة باستخدام Gemini 📸 أداة توليد وصف وكلمات مفتاحية باستخدام Gemini API ✨ تحليل الصورة 📄 العنوا...

جميع الحقوق محفوظة © exmpal2025

المساعد الذكي للمدونة

أهلاً بك! أنا مساعدك الشخصي في مدونة exmpal2025. كيف يمكنني مساعدتك اليوم؟ يمكنك سؤالي عن أي مقال أو موضوع في المدونة.

مدعوم بواسطة MOPlus

شرح وتوضيح الفقرة