You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, intensity = 50, sparklesCount = 45, theme = "gold", seed = 1337) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const width = originalImg.width;
const height = originalImg.height;
canvas.width = width;
canvas.height = height;
// Apply color boost to make the image jump out (Lucky charm card effect)
const valSaturate = 100 + Number(intensity);
const valContrast = 100 + (Number(intensity) / 2);
ctx.filter = `saturate(${valSaturate}%) contrast(${valContrast}%)`;
ctx.drawImage(originalImg, 0, 0, width, height);
ctx.filter = 'none';
// Simple Pseudo-Random Number Generator for consistent "luck" based on seed
let currentSeed = Number(seed);
const random = () => {
let x = Math.sin(currentSeed++) * 10000;
return x - Math.floor(x);
};
// 1. Add "Shiny Foil" overlay
ctx.globalCompositeOperation = 'overlay';
const grad = ctx.createLinearGradient(0, 0, width, height);
const selectedTheme = String(theme).toLowerCase();
if (selectedTheme === 'rainbow') {
grad.addColorStop(0, '#ff2a2a');
grad.addColorStop(0.16, '#ff7a2a');
grad.addColorStop(0.33, '#e8ff2a');
grad.addColorStop(0.5, '#2aff30');
grad.addColorStop(0.66, '#2a30ff');
grad.addColorStop(0.83, '#c22aff');
grad.addColorStop(1, '#ff2a2a');
} else if (selectedTheme === 'emerald') {
grad.addColorStop(0, '#00ff87');
grad.addColorStop(0.5, '#60efff');
grad.addColorStop(1, '#00ff87');
} else {
// Gold / Default theme
grad.addColorStop(0, '#bf953f');
grad.addColorStop(0.25, '#fcf6ba');
grad.addColorStop(0.5, '#b38728');
grad.addColorStop(0.75, '#fbf5b7');
grad.addColorStop(1, '#aa771c');
}
// Apply foil with variable intensity opacity
ctx.globalAlpha = (Number(intensity) / 100) * 0.7 + 0.1;
ctx.fillStyle = grad;
ctx.fillRect(0, 0, width, height);
// 2. Add sparkles
ctx.globalCompositeOperation = 'screen';
const maxDim = Math.max(width, height);
for (let i = 0; i < Number(sparklesCount); i++) {
const x = random() * width;
const y = random() * height;
const size = (random() * 0.05 + 0.01) * maxDim; // Sparkles dynamically scaled to image size
const opacity = random() * 0.6 + 0.4;
ctx.save();
ctx.translate(x, y);
ctx.globalAlpha = opacity;
// Draw dramatic star shape for the sparkle
ctx.beginPath();
ctx.moveTo(0, -size);
ctx.quadraticCurveTo(0, 0, size, 0);
ctx.quadraticCurveTo(0, 0, 0, size);
ctx.quadraticCurveTo(0, 0, -size, 0);
ctx.quadraticCurveTo(0, 0, 0, -size);
ctx.closePath();
// Sparkle coloring based on theme
const starGrad = ctx.createRadialGradient(0, 0, 0, 0, 0, size);
starGrad.addColorStop(0, 'rgba(255, 255, 255, 1)');
if (selectedTheme === 'gold') {
starGrad.addColorStop(0.2, 'rgba(255, 220, 100, 0.8)');
starGrad.addColorStop(1, 'rgba(255, 200, 0, 0)');
} else if (selectedTheme === 'emerald') {
starGrad.addColorStop(0.2, 'rgba(100, 255, 150, 0.8)');
starGrad.addColorStop(1, 'rgba(0, 255, 100, 0)');
} else {
// Rainbow / Silver
starGrad.addColorStop(0.2, 'rgba(220, 220, 255, 0.8)');
starGrad.addColorStop(1, 'rgba(100, 150, 255, 0)');
}
ctx.fillStyle = starGrad;
ctx.fill();
// Add an extra thin bright flare
ctx.rotate(random() * Math.PI);
ctx.beginPath();
ctx.ellipse(0, 0, size * 1.5, size * 0.05, 0, 0, Math.PI * 2);
ctx.fillStyle = 'rgba(255, 255, 255, 0.6)';
ctx.fill();
ctx.restore();
}
// 3. Add soft dark vignette to enhance focus on the center
ctx.globalCompositeOperation = 'multiply';
ctx.globalAlpha = 1.0;
const vigGrad = ctx.createRadialGradient(width/2, height/2, maxDim * 0.3, width/2, height/2, maxDim);
vigGrad.addColorStop(0, 'rgba(0, 0, 0, 0)');
vigGrad.addColorStop(1, 'rgba(0, 0, 0, 0.4)');
ctx.fillStyle = vigGrad;
ctx.fillRect(0, 0, width, height);
return canvas;
}
Apply Changes