You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, subtitleText = "Hello, welcome back to the channel. (Translated)", dubLanguage = "English (Dubbed)", platformName = "DVDRip Player", showAudioMenu = 1) {
const canvas = document.createElement('canvas');
// Capture dimensions and handle fallbacks safely
const w = originalImg.naturalWidth || originalImg.width || 800;
const h = originalImg.naturalHeight || originalImg.height || 600;
canvas.width = w;
canvas.height = h;
const ctx = canvas.getContext('2d');
// Draw the original image as a base
ctx.drawImage(originalImg, 0, 0, w, h);
// Calculate dynamic UI scaling strictly based on image width to keep it responsive
const scale = Math.max(w / 1000, 0.4);
const barHeight = 70 * scale;
const padding = 20 * scale;
// Dark cinematic gradient for the video player controls background
const grad = ctx.createLinearGradient(0, h - barHeight * 2, 0, h);
grad.addColorStop(0, 'rgba(0, 0, 0, 0)');
grad.addColorStop(1, 'rgba(0, 0, 0, 0.85)');
ctx.fillStyle = grad;
ctx.fillRect(0, h - barHeight * 2, w, barHeight * 2);
// Render Translator Subtitles
if (subtitleText && subtitleText.trim() !== '') {
const subSize = 34 * scale;
ctx.font = `bold ${subSize}px Arial, sans-serif`;
ctx.textAlign = 'center';
ctx.textBaseline = 'bottom';
const subX = w / 2;
const subY = h - barHeight - 20 * scale;
// Add thick border for readability
ctx.lineJoin = 'round';
ctx.lineWidth = 5 * scale;
ctx.strokeStyle = '#000000';
ctx.strokeText(subtitleText, subX, subY);
// Fill text with yellow simulating standard film subtitle translations
ctx.fillStyle = '#ffdf00';
ctx.fillText(subtitleText, subX, subY);
}
// Audio Track Dubbing / Menu Overlay (The 'Translator Tool' settings UI)
if (Number(showAudioMenu) === 1) {
const menuWidth = 300 * scale;
const menuHeight = 220 * scale;
// Prevent layout break on very narrow images
const safeMenuW = Math.min(menuWidth, w - 20);
const menuX = Math.max(10, w - padding - safeMenuW);
const menuY = h - barHeight - 15 * scale - menuHeight;
// Draw Settings Panel
ctx.fillStyle = 'rgba(20, 20, 20, 0.92)';
ctx.fillRect(menuX, menuY, safeMenuW, menuHeight);
ctx.strokeStyle = 'rgba(255, 255, 255, 0.15)';
ctx.lineWidth = 1 * Math.max(1, scale);
ctx.strokeRect(menuX, menuY, safeMenuW, menuHeight);
// Header Title
ctx.textAlign = 'left';
ctx.textBaseline = 'top';
ctx.font = `bold ${18 * scale}px Arial, sans-serif`;
ctx.fillStyle = '#ffffff';
ctx.fillText("Audio Track / Settings", menuX + 20 * scale, menuY + 20 * scale);
ctx.beginPath();
ctx.moveTo(menuX, menuY + 50 * scale);
ctx.lineTo(menuX + safeMenuW, menuY + 50 * scale);
ctx.stroke();
// Audio Source Select
ctx.font = `bold ${15 * scale}px Arial, sans-serif`;
ctx.fillStyle = '#a1a1a1';
ctx.fillText("Audio Channel:", menuX + 20 * scale, menuY + 65 * scale);
ctx.font = `${15 * scale}px Arial, sans-serif`;
ctx.fillStyle = '#ffffff';
ctx.fillText("○ Original Audio", menuX + 20 * scale, menuY + 90 * scale);
// Selected Dubbing Option
ctx.fillStyle = '#00a8ff'; // Active highlight
ctx.fillText("● " + dubLanguage, menuX + 20 * scale, menuY + 115 * scale);
// Translator Tool Layer
ctx.font = `bold ${15 * scale}px Arial, sans-serif`;
ctx.fillStyle = '#a1a1a1';
ctx.fillText("Video Text Translator:", menuX + 20 * scale, menuY + 155 * scale);
ctx.font = `${15 * scale}px Arial, sans-serif`;
ctx.fillStyle = '#00a8ff';
ctx.fillText("● Auto-Trans Subtitles (On)", menuX + 20 * scale, menuY + 180 * scale);
}
// Bottom solid overlay for controls
ctx.fillStyle = 'rgba(0, 0, 0, 0.7)';
ctx.fillRect(0, h - barHeight, w, barHeight);
// Timeline Progress Bar Track
const progressY = h - barHeight + padding;
ctx.fillStyle = '#444444';
ctx.fillRect(padding, progressY, w - padding * 2, 6 * scale);
// Timeline Filled Progress (Red like common video players)
const progressPct = 0.42;
ctx.fillStyle = '#e50914';
ctx.fillRect(padding, progressY, (w - padding * 2) * progressPct, 6 * scale);
// Scrubber Knob
ctx.beginPath();
ctx.arc(padding + (w - padding * 2) * progressPct, progressY + 3 * scale, 8 * scale, 0, Math.PI * 2);
ctx.fillStyle = '#e50914';
ctx.fill();
// Standard Player Controls Y-Offset
const controlsY = progressY + 15 * scale;
const playSize = 16 * scale;
// Play icon triangle
ctx.fillStyle = '#ffffff';
ctx.beginPath();
ctx.moveTo(padding, controlsY);
ctx.lineTo(padding + playSize, controlsY + playSize / 2);
ctx.lineTo(padding, controlsY + playSize);
ctx.fill();
// Timestamp
ctx.font = `${14 * scale}px Arial, sans-serif`;
ctx.textAlign = 'left';
ctx.textBaseline = 'middle';
ctx.fillStyle = '#dddddd';
ctx.fillText("00:42:15 / 01:29:43", padding + playSize + 20 * scale, controlsY + playSize / 2);
// Output right-side items (Platform flag, Volume, Settings mock layout)
ctx.textAlign = 'right';
const textW = ctx.measureText(platformName).width;
ctx.fillStyle = '#888888';
ctx.fillText(platformName, w - padding, controlsY + playSize / 2);
ctx.font = `bold ${18 * scale}px sans-serif`;
ctx.fillStyle = '#ffffff';
// Settings, Audio Track Dub Icon, Volume Icon
ctx.fillText("⚙ 💬 🔊", w - padding - textW - 20 * scale, controlsY + playSize / 2);
return canvas;
}
Apply Changes