You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, intensity = 1, redTint = 1) {
const canvas = document.createElement('canvas');
canvas.width = originalImg.width;
canvas.height = originalImg.height;
if (canvas.width === 0 || canvas.height === 0) {
return canvas;
}
const ctx = canvas.getContext('2d');
// Parse parameters robustly
const intensityNum = isNaN(Number(intensity)) ? 1 : Number(intensity);
const redNum = isNaN(Number(redTint)) ? 1 : Number(redTint);
// First layer: draw the adjusted image to a temporary canvas
const tempCanvas = document.createElement('canvas');
tempCanvas.width = canvas.width;
tempCanvas.height = canvas.height;
const tempCtx = tempCanvas.getContext('2d');
// 1. Apply angry contrast, brightness, and saturation
const contrast = Math.max(0, 100 + 50 * intensityNum);
const saturate = Math.max(0, 100 + 50 * intensityNum);
const bright = Math.max(0, 100 - 10 * intensityNum);
tempCtx.filter = `contrast(${contrast}%) saturate(${saturate}%) brightness(${bright}%)`;
tempCtx.drawImage(originalImg, 0, 0);
// Reset filter for subsequent operations
tempCtx.filter = 'none';
// 2. Apply Deep Red overlay
const redAlpha = Math.max(0, Math.min(1, 0.4 * redNum));
if (redAlpha > 0) {
tempCtx.globalCompositeOperation = 'multiply';
tempCtx.fillStyle = `rgba(255, 0, 0, ${redAlpha})`;
tempCtx.fillRect(0, 0, canvas.width, canvas.height);
}
// 3. Apply menacing Vignette shading to edges
tempCtx.globalCompositeOperation = 'multiply';
const gradient = tempCtx.createRadialGradient(
canvas.width / 2, canvas.height / 2,
Math.min(canvas.width, canvas.height) / 4,
canvas.width / 2, canvas.height / 2,
Math.max(canvas.width, canvas.height) / 1.2
);
// Increase darkness and redness matching the intensity
const edgeRed = Math.max(75, Math.min(255, Math.floor(255 - 155 * intensityNum)));
const edgeGB = Math.max(0, Math.min(255, Math.floor(255 - 255 * intensityNum)));
gradient.addColorStop(0, 'rgba(255, 255, 255, 1)'); // Center stays normal
gradient.addColorStop(1, `rgb(${edgeRed}, ${edgeGB}, ${edgeGB})`); // Outer edge turns dark / deep red
tempCtx.fillStyle = gradient;
tempCtx.fillRect(0, 0, canvas.width, canvas.height);
// 4. Second pass: Draw processed image to final canvas applying chaotic Zoom-Blur and Shake
const steps = Math.max(1, Math.floor(20 * intensityNum));
const maxScale = 1 + 0.15 * intensityNum;
const maxShakeX = canvas.width * 0.01 * intensityNum;
const maxShakeY = canvas.height * 0.01 * intensityNum;
ctx.imageSmoothingEnabled = true;
for (let i = 0; i < steps; i++) {
let scale = 1;
let offsetX = 0;
let offsetY = 0;
if (i > 0) {
// Gradually scale up for the zoom blur setup
scale = 1 + (maxScale - 1) * (i / steps);
// Random displacement for the chaotic shake effect
offsetX = (Math.random() * 2 - 1) * maxShakeX;
offsetY = (Math.random() * 2 - 1) * maxShakeY;
}
// This specific inverse alpha blending natively yields a perfectly smooth arithmetic average of frames
ctx.globalAlpha = 1 / (i + 1);
ctx.save();
ctx.translate(canvas.width / 2 + offsetX, canvas.height / 2 + offsetY);
ctx.scale(scale, scale);
ctx.translate(-canvas.width / 2, -canvas.height / 2);
ctx.drawImage(tempCanvas, 0, 0);
ctx.restore();
}
return canvas;
}
Apply Changes