File manager - Edit - /home/kridsana/webapp.cm.in.th/673190902/u67319090017/remove-bg-web/static/app.js
Back
const fileInput = document.getElementById("fileInput"); const preview = document.getElementById("preview"); const result = document.getElementById("result"); const statusEl = document.getElementById("status"); const downloadLink = document.getElementById("download"); const modeEl = document.getElementById("mode"); const blurEl = document.getElementById("blur_ksize"); const thrEl = document.getElementById("threshold"); const lowEl = document.getElementById("canny_low"); const highEl = document.getElementById("canny_high"); const featherEl = document.getElementById("feather"); let currentFile = null; fileInput.addEventListener("change", () => { const f = fileInput.files?.[0]; if (!f) return; currentFile = f; preview.src = URL.createObjectURL(f); result.removeAttribute("src"); downloadLink.removeAttribute("href"); statusEl.textContent = ""; }); function buildFormData() { const fd = new FormData(); fd.append("image", currentFile); fd.append("mode", modeEl.value); fd.append("blur_ksize", blurEl.value); fd.append("threshold", thrEl.value); fd.append("canny_low", lowEl.value); fd.append("canny_high", highEl.value); fd.append("feather", featherEl.value); return fd; } async function callApi(path) { if (!currentFile) { statusEl.textContent = "กรุณาเลือกรูปก่อน"; return; } statusEl.textContent = "กำลังประมวลผล..."; try { const res = await fetch(path, { method: "POST", body: buildFormData() }); if (!res.ok) throw new Error("API error: " + res.status); const blob = await res.blob(); const url = URL.createObjectURL(blob); result.src = url; downloadLink.href = url; downloadLink.style.display = "inline-block"; statusEl.textContent = "เสร็จแล้ว ✅"; } catch (err) { statusEl.textContent = "เกิดข้อผิดพลาด: " + err.message; } } document.getElementById("btnProcess").addEventListener("click", () => { callApi("/api/remove-bg"); }); document.getElementById("btnMask").addEventListener("click", () => { // mask endpoint ignores feather callApi("/api/mask"); });
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.37 |
proxy
|
phpinfo
|
Settings