You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, intensity = 0.6, warmth = 0.7) {
// Restrict parameters to sensible boundaries for safe math
const safeIntensity = Math.max(0, Math.min(1, Number(intensity) || 0));
const safeWarmth = Math.max(0, Math.min(1, Number(warmth) || 0));
const width = originalImg.width;
const height = originalImg.height;
// Create the main canvas
const canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext('2d');
// 1. Base Image - Boost contrast and saturation slightly
ctx.filter = `contrast(${1 + 0.15 * safeIntensity}) saturate(${1 + 0.4 * safeWarmth})`;
ctx.drawImage(originalImg, 0, 0);
ctx.filter = 'none';
// 2. Warm Color Overlay
// Soft-light blends gently into the mid-tones, increasing warmth
ctx.globalCompositeOperation = 'soft-light';
ctx.fillStyle = `rgba(255, 140, 0, ${safeWarmth * 0.5})`; // Golden/orange tint
ctx.fillRect(0, 0, width, height);
// 3. Directional Sun Overlay (Radial Gradient)
// Simulates a sun source coming from the top center
ctx.globalCompositeOperation = 'overlay';
const sunGradient = ctx.createRadialGradient(
width / 2, 0, height * 0.05, // Inner circle (top center)
width / 2, 0, Math.max(width, height) // Outer circle
);
sunGradient.addColorStop(0, `rgba(255, 210, 120, ${safeWarmth * 0.6})`);
sunGradient.addColorStop(0.5, `rgba(255, 120, 20, ${safeWarmth * 0.2})`);
sunGradient.addColorStop(1, `rgba(0, 0, 0, 0)`);
ctx.fillStyle = sunGradient;
ctx.fillRect(0, 0, width, height);
// 4. Bloom / Glow Effect
// Draw the image again with 'screen' blending and high blur to create the soft, glowing light
ctx.globalCompositeOperation = 'screen';
ctx.globalAlpha = safeIntensity * 0.45;
// Calculate a proportional, bounded blur radius
const blurRadius = Math.min(Math.max(width, height) * 0.03 * safeIntensity, 60);
// Add sepia to the glow to make it extra warm and bright
ctx.filter = `blur(${blurRadius}px) contrast(1.3) sepia(${0.6 * safeWarmth})`;
ctx.drawImage(originalImg, 0, 0);
// Reset context before adding the final touch
ctx.globalAlpha = 1.0;
ctx.filter = 'none';
// 5. Subtle Vignette
// Focuses the light on the center/top by gently darkening the edges
const vignette = ctx.createRadialGradient(
width / 2, height / 2, Math.max(width, height) * 0.4,
width / 2, height / 2, Math.max(width, height) * 0.85
);
vignette.addColorStop(0, 'rgba(0,0,0,0)');
vignette.addColorStop(1, `rgba(40,10,0,${0.35 * safeIntensity})`); // Warm dark vignette
ctx.globalCompositeOperation = 'multiply';
ctx.fillStyle = vignette;
ctx.fillRect(0, 0, width, height);
return canvas;
}
Apply Changes