You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, intensityLevel = 1, glitchAmount = 1) {
// Parse parameters to ensure they are treated as numbers
intensityLevel = Number(intensityLevel) || 1;
glitchAmount = Number(glitchAmount) || 1;
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const w = originalImg.width;
const h = originalImg.height;
canvas.width = w;
canvas.height = h;
// Draw original image to access its pixel data
ctx.drawImage(originalImg, 0, 0, w, h);
// Get pixel data
const imgData = ctx.getImageData(0, 0, w, h);
const data = imgData.data;
const outData = new Uint8ClampedArray(data.length);
// Calculate chromatic aberration offset based on intensity
const offset = Math.floor(5 * intensityLevel);
// Filter Step 1: Pixel Manipulation -> Demonic red tint, contrast, noise, and RGB split
for (let y = 0; y < h; y++) {
for (let x = 0; x < w; x++) {
const i = (y * w + x) * 4;
// RGB Shift (Chromatic Aberration)
// Left offset for red, right offset for blue
const iR = (y * w + Math.max(0, x - offset)) * 4;
const iB = (y * w + Math.min(w - 1, x + offset)) * 4;
let r = data[iR];
let g = data[i + 1];
let b = data[iB + 2];
// Increase Contrast significantly for a harsh "scary" look
const contrast = 1.5 + (0.5 * intensityLevel);
r = ((r / 255 - 0.5) * contrast + 0.5) * 255;
g = ((g / 255 - 0.5) * contrast + 0.5) * 255;
b = ((b / 255 - 0.5) * contrast + 0.5) * 255;
// Demonic Tint: Boost deep reds, heavily mute greens and blues
r = r * 1.3 + 30; // Boost red and raise baseline
g = g * 0.3; // Suppress green
b = b * 0.3; // Suppress blue
// Introduce heavy static/noise
const noise = (Math.random() - 0.5) * 70 * intensityLevel;
r += noise;
g += noise;
b += noise;
// Output to new array
outData[i] = r;
outData[i + 1] = g;
outData[i + 2] = b;
outData[i + 3] = data[i + 3]; // Preserve original alpha
}
}
// Apply processed pixels back to canvas
const newImgData = new ImageData(outData, w, h);
ctx.putImageData(newImgData, 0, 0);
// Filter Step 2: Horizontal Glitch / Tearing Effect
const numGlitches = Math.floor(15 * glitchAmount);
for (let i = 0; i < numGlitches; i++) {
const glitchY = Math.random() * h;
const glitchH = Math.random() * (h / 15) + 2;
const glitchOffsetX = (Math.random() - 0.5) * 120 * glitchAmount;
if (glitchY + glitchH < h) {
const sliceData = ctx.getImageData(0, glitchY, w, glitchH);
// Draw a dark void underneath the tear
ctx.fillStyle = Math.random() > 0.5 ? '#1a0000' : '#000000';
ctx.fillRect(0, glitchY, w, glitchH);
// Place the torn slice offset
ctx.putImageData(sliceData, glitchOffsetX, glitchY);
}
}
// Filter Step 3: Scanlines (for the "Volume" / VHS distortion vibe)
ctx.fillStyle = 'rgba(0, 0, 0, 0.3)';
for (let y = 0; y < h; y += 4) {
ctx.fillRect(0, y, w, 1);
}
// Filter Step 4: Heavy Vignette (Creepy darkening around the edges)
const grad = ctx.createRadialGradient(w / 2, h / 2, 0, w / 2, h / 2, Math.max(w, h) / 1.1);
grad.addColorStop(0, 'rgba(0, 0, 0, 0)');
grad.addColorStop(0.6, 'rgba(30, 0, 0, 0.5)'); // Dark bloody red transition
grad.addColorStop(1, 'rgba(0, 0, 0, 0.98)'); // Almost pitch black edges
ctx.fillStyle = grad;
ctx.fillRect(0, 0, w, h);
// Final Touch: Red Blood Overlay Synthesis
ctx.fillStyle = 'rgba(150, 0, 0, 0.15)';
ctx.globalCompositeOperation = 'overlay';
ctx.fillRect(0, 0, w, h);
ctx.globalCompositeOperation = 'source-over';
return canvas;
}
Apply Changes