You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(
originalImg,
subtitleText = "I have translated the audio to text.",
language = "[ENG DUB]",
vhsDetails = "VHSRip HIFI MONO",
intensity = 15
) {
// Determine dimensions
const w = originalImg.width;
const h = originalImg.height;
// Create and configure canvas object
const canvas = document.createElement('canvas');
canvas.width = w;
canvas.height = h;
const ctx = canvas.getContext('2d');
// Draw the initial image
ctx.drawImage(originalImg, 0, 0, w, h);
// Fetch pixel data to apply the "VHSRip" effect
const imgData = ctx.getImageData(0, 0, w, h);
const data = imgData.data;
const outData = new Uint8ClampedArray(data.length);
// VHS effect math values
const shiftMag = Math.floor(w * (intensity / 2000));
const noiseLevel = intensity * 1.5;
const trackingY1 = Math.floor(h * 0.82);
const trackingY2 = Math.floor(h * 0.86);
for (let y = 0; y < h; y++) {
let dX = 0;
// Tracking error glitch at bottom
if (y > trackingY1 && y < trackingY2) {
dX = Math.floor((Math.random() - 0.5) * shiftMag * 10);
}
for (let x = 0; x < w; x++) {
const i = (y * w + x) * 4;
// Chromatic Aberration RGB Shift Calculation
let rx = x + shiftMag + dX;
let gx = x + dX;
let bx = x - shiftMag + dX;
// Clamp coordinates to bounds
rx = Math.max(0, Math.min(w - 1, rx));
gx = Math.max(0, Math.min(w - 1, gx));
bx = Math.max(0, Math.min(w - 1, bx));
const ri = (y * w + rx) * 4;
const gi = (y * w + gx) * 4;
const bi = (y * w + bx) * 4;
outData[i] = data[ri]; // Red channel shifted
outData[i + 1] = data[gi + 1]; // Green channel center (with tracking)
outData[i + 2] = data[bi + 2]; // Blue channel shifted
// Add static noise
let noise = (Math.random() - 0.5) * noiseLevel;
outData[i] = Math.min(255, Math.max(0, outData[i] + noise));
outData[i + 1] = Math.min(255, Math.max(0, outData[i + 1] + noise));
outData[i + 2] = Math.min(255, Math.max(0, outData[i + 2] + noise));
// VCR Scanlines
if (y % 4 < 2) {
outData[i] = Math.max(0, outData[i] - 15);
outData[i + 1] = Math.max(0, outData[i + 1] - 15);
outData[i + 2] = Math.max(0, outData[i + 2] - 15);
}
outData[i + 3] = data[i + 3]; // Preserve original Alpha
}
}
// Apply pixel modifications back to canvas
ctx.putImageData(new ImageData(outData, w, h), 0, 0);
// Apply "Language Translator / Dub Text" Overlay (DVDRip / Anime style subtitling)
const subFontSize = Math.max(16, Math.floor(h * 0.05));
ctx.font = `bold ${subFontSize}px Arial, sans-serif`;
ctx.textAlign = 'center';
ctx.textBaseline = 'bottom';
ctx.lineJoin = 'round';
const translatedString = `${language} ${subtitleText}`;
// Translators Subtitle properties
ctx.lineWidth = Math.max(3, Math.floor(subFontSize * 0.15));
ctx.strokeStyle = 'black';
ctx.fillStyle = '#ffec19'; // Classic dub yellow
// Draw subtitle outline, then fill
ctx.strokeText(translatedString, w / 2, h - (h * 0.05));
ctx.fillText(translatedString, w / 2, h - (h * 0.05));
// VCR OSD (On-Screen Display) "Player" Overlays
const osdFontSize = Math.max(14, Math.floor(h * 0.04));
ctx.font = `bold ${osdFontSize}px "Courier New", Courier, monospace`;
ctx.textAlign = 'left';
ctx.textBaseline = 'top';
// Adding subtle drop shadow to VCR text to match traditional CRTs
ctx.shadowColor = 'black';
ctx.shadowBlur = 4;
ctx.shadowOffsetX = 2;
ctx.shadowOffsetY = 2;
ctx.fillStyle = '#00ff41'; // VCR Green tint
// PLAY indicator
ctx.fillText("PLAY ►", w * 0.05, h * 0.05);
// Details text
ctx.textAlign = 'right';
ctx.fillText(vhsDetails, w * 0.95, h * 0.05);
// Reset styles
ctx.shadowColor = 'transparent';
return canvas;
}
Apply Changes