You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, drawCross = "true", crossColor = "rgba(200, 20, 20, 0.8)", contrastLevel = "60", vignetteIntensity = "0.7", overlayText = "") {
const canvas = document.createElement('canvas');
const width = originalImg.width;
const height = originalImg.height;
// Set canvas dimensions
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext('2d');
// 1. Draw the original image onto the canvas
ctx.drawImage(originalImg, 0, 0);
// 2. Apply Grunge/Cinematic "Losky" Filter (Contrast, Gritty Desaturation)
const contrast = parseFloat(contrastLevel);
if (!isNaN(contrast) && contrast !== 0) {
const imgData = ctx.getImageData(0, 0, width, height);
const data = imgData.data;
// Typical contrast adjustment formula
const factor = (259 * (contrast + 255)) / (255 * (259 - contrast));
for (let i = 0; i < data.length; i += 4) {
let r = data[i];
let g = data[i + 1];
let b = data[i + 2];
// Apply Contrast
r = factor * (r - 128) + 128;
g = factor * (g - 128) + 128;
b = factor * (b - 128) + 128;
// Apply slight desaturation for a gritty feel
const lum = 0.299 * r + 0.587 * g + 0.114 * b;
r = r * 0.75 + lum * 0.25;
g = g * 0.75 + lum * 0.25;
b = b * 0.75 + lum * 0.25;
// Apply a cinematic split-tone (warm shadows, cool highlights)
if (lum < 110) {
r += 12; // Boost reds in shadows
b -= 5;
} else {
b += 12; // Boost blues in highlights
r -= 5;
}
// Clamp values between 0 and 255
data[i] = Math.min(255, Math.max(0, r));
data[i + 1] = Math.min(255, Math.max(0, g));
data[i + 2] = Math.min(255, Math.max(0, b));
}
ctx.putImageData(imgData, 0, 0);
}
// 3. Apply Vignette Effect
const vIntensity = parseFloat(vignetteIntensity);
if (!isNaN(vIntensity) && vIntensity > 0) {
const gradient = ctx.createRadialGradient(
width / 2, height / 2, Math.min(width, height) * 0.25,
width / 2, height / 2, Math.max(width, height) * 0.75
);
gradient.addColorStop(0, 'rgba(0, 0, 0, 0)');
// Opacity of vignette scales with the intensity parameter
gradient.addColorStop(1, `rgba(0, 0, 0, ${Math.min(1, vIntensity)})`);
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, width, height);
}
// 4. Draw the "I Killed X" cross mark over the screen
if (String(drawCross).toLowerCase() === 'true' || drawCross === '1') {
const marginX = width * 0.15;
const marginY = height * 0.15;
// Draw main colored cross
ctx.beginPath();
ctx.moveTo(marginX, marginY);
ctx.lineTo(width - marginX, height - marginY);
ctx.moveTo(width - marginX, marginY);
ctx.lineTo(marginX, height - marginY);
ctx.strokeStyle = crossColor;
ctx.lineWidth = Math.min(width, height) * 0.08;
ctx.lineCap = 'round';
ctx.stroke();
// Draw a slim dark inner line to make it look like a physical marker/stamp
ctx.beginPath();
ctx.moveTo(marginX, marginY);
ctx.lineTo(width - marginX, height - marginY);
ctx.moveTo(width - marginX, marginY);
ctx.lineTo(marginX, height - marginY);
ctx.strokeStyle = 'rgba(0, 0, 0, 0.4)';
ctx.lineWidth = Math.min(width, height) * 0.025;
ctx.lineCap = 'round';
ctx.stroke();
}
// 5. Optional Text Overlay (e.g., "ELIMINATED", "LOSKY")
if (overlayText && overlayText.trim() !== "") {
const fontSize = Math.max(20, Math.min(width, height) * 0.12);
ctx.font = `900 ${fontSize}px "Impact", "Arial Black", sans-serif`;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
const textY = height * 0.88;
// Text Shadow / Outline for great visibility
ctx.lineWidth = Math.max(2, Math.min(width, height) * 0.015);
ctx.strokeStyle = 'black';
ctx.strokeText(overlayText.toUpperCase(), width / 2, textY);
// Text Fill
ctx.fillStyle = '#f4f4f4';
ctx.fillText(overlayText.toUpperCase(), width / 2, textY);
}
return canvas;
}
Apply Changes