You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(
originalImg,
contrast = 1.3,
brightness = 0.95,
exposure = 1.1,
blackPoint = 15,
gamma = 0.9,
vignetteIntensity = 0.85,
vignetteRadius = 0.4,
grainIntensity = 45,
dustCount = 200,
scratchCount = 25,
blurEdgesRadius = 5,
redChannelMix = 0.0,
greenChannelMix = 0.3,
blueChannelMix = 0.7,
sepiaTone = 0.2,
chemicalSpill = 0.4,
borderThickness = 0.04,
borderIrregularity = 1.0,
halationIntensity = 0.5,
lightLeakIntensity = 0.3
) {
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. Draw base image
ctx.drawImage(originalImg, 0, 0);
// 2. Extract pixels for Color Mixing, Tone, Contrast & Grain
const imgData = ctx.getImageData(0, 0, width, height);
const data = imgData.data;
const limit = (val) => Math.min(255, Math.max(0, val));
for (let i = 0; i < data.length; i += 4) {
let r = data[i];
let g = data[i + 1];
let b = data[i + 2];
// Apply 1880s Orthochromatic Film channel mix (blind to red, highly sensitive to blue)
let intensity = (r * redChannelMix) + (g * greenChannelMix) + (b * blueChannelMix);
// Apply Exposure
intensity *= exposure;
// Apply Gamma curve
intensity = 255 * Math.pow(intensity / 255, gamma);
// Apply Contrast and Brightness
intensity = ((intensity / 255 - 0.5) * contrast + 0.5) * 255;
intensity *= brightness;
// Lift black point (faded shadows)
intensity = intensity + (blackPoint * (1 - intensity / 255));
// Add Sepia / Silver-gelatin tone
let outR = intensity + (40 * sepiaTone);
let outG = intensity + (15 * sepiaTone);
let outB = intensity - (20 * sepiaTone);
// Apply Film Grain
let noise = (Math.random() - 0.5) * grainIntensity;
data[i] = limit(outR + noise);
data[i + 1] = limit(outG + noise);
data[i + 2] = limit(outB + noise);
data[i + 3] = 255; // Remove any transparency
}
ctx.putImageData(imgData, 0, 0);
// 3. Halation (Bright areas bloom, typical of old anti-halation lacking film)
if (halationIntensity > 0) {
const halCanvas = document.createElement('canvas');
halCanvas.width = width;
halCanvas.height = height;
const hCtx = halCanvas.getContext('2d');
hCtx.drawImage(canvas, 0, 0);
const hData = hCtx.getImageData(0, 0, width, height);
for (let i = 0; i < hData.data.length; i += 4) {
let luma = hData.data[i]*0.3 + hData.data[i+1]*0.59 + hData.data[i+2]*0.11;
// Only keep the brightest elements threshold
if (luma < 180) {
hData.data[i+3] = 0;
} else {
hData.data[i+3] = ((luma - 180) / 75) * 255;
}
}
hCtx.putImageData(hData, 0, 0);
const glowCanvas = document.createElement('canvas');
glowCanvas.width = width;
glowCanvas.height = height;
const gCtx = glowCanvas.getContext('2d');
gCtx.filter = `blur(${Math.max(width, height) * 0.015}px)`;
gCtx.drawImage(halCanvas, 0, 0);
ctx.globalAlpha = halationIntensity;
ctx.globalCompositeOperation = 'screen';
ctx.drawImage(glowCanvas, 0, 0);
ctx.globalAlpha = 1.0;
ctx.globalCompositeOperation = 'source-over';
}
// 4. Edge Lens Blur (Petzval / early lens spherical aberration)
if (blurEdgesRadius > 0) {
const blurCanvas = document.createElement('canvas');
blurCanvas.width = width;
blurCanvas.height = height;
const bCtx = blurCanvas.getContext('2d');
bCtx.filter = `blur(${blurEdgesRadius}px)`;
bCtx.drawImage(canvas, 0, 0);
const maskCanvas = document.createElement('canvas');
maskCanvas.width = width;
maskCanvas.height = height;
const mCtx = maskCanvas.getContext('2d');
const rGrad = mCtx.createRadialGradient(width/2, height/2, 0, width/2, height/2, Math.max(width, height)/1.6);
rGrad.addColorStop(0, 'rgba(0,0,0,0)'); // Sharp center
rGrad.addColorStop(0.5, 'rgba(0,0,0,0)');
rGrad.addColorStop(1, 'rgba(0,0,0,1)'); // Blurred edges
mCtx.fillStyle = rGrad;
mCtx.fillRect(0, 0, width, height);
mCtx.globalCompositeOperation = 'source-in';
mCtx.drawImage(blurCanvas, 0, 0);
ctx.drawImage(maskCanvas, 0, 0);
}
// 5. Heavy Vignette
if (vignetteIntensity > 0) {
const vGrad = ctx.createRadialGradient(
width/2, height/2, Math.max(width, height) * vignetteRadius * 0.5,
width/2, height/2, Math.max(width, height) * 0.8
);
vGrad.addColorStop(0, 'rgba(255,255,255,1)');
const vDark = Math.floor(255 * (1 - vignetteIntensity));
vGrad.addColorStop(1, `rgba(${vDark},${vDark},${vDark},1)`);
ctx.globalCompositeOperation = 'multiply';
ctx.fillStyle = vGrad;
ctx.fillRect(0, 0, width, height);
ctx.globalCompositeOperation = 'source-over';
}
// 6. Chemical Spills / Emulsion artifacts (edges mostly)
if (chemicalSpill > 0) {
ctx.globalAlpha = chemicalSpill;
ctx.globalCompositeOperation = 'overlay';
let spillCount = Math.floor(Math.random() * 4) + 3;
for (let i = 0; i < spillCount; i++) {
let cx = (Math.random() > 0.5 ? 0 : width) + (Math.random()-0.5) * width * 0.3;
let cy = (Math.random() > 0.5 ? 0 : height) + (Math.random()-0.5) * height * 0.3;
let r = Math.random() * width * 0.5 + width * 0.2;
let cGrad = ctx.createRadialGradient(cx, cy, 0, cx, cy, r);
let color = Math.random() > 0.5 ? '40,20,10' : '200,190,160';
cGrad.addColorStop(0, `rgba(${color}, 0.7)`);
cGrad.addColorStop(1, `rgba(${color}, 0)`);
ctx.fillStyle = cGrad;
ctx.fillRect(0, 0, width, height);
}
ctx.globalAlpha = 1.0;
ctx.globalCompositeOperation = 'source-over';
}
// 7. Light Leaks
if (lightLeakIntensity > 0) {
ctx.globalCompositeOperation = 'screen';
ctx.globalAlpha = lightLeakIntensity;
let leakX = Math.random() > 0.5 ? 0 : width;
let lGrad = ctx.createLinearGradient(leakX, 0, Math.abs(width/2 - leakX), height * 0.6);
lGrad.addColorStop(0, 'rgba(255, 235, 210, 0.8)');
lGrad.addColorStop(1, 'rgba(255, 255, 255, 0)');
ctx.fillStyle = lGrad;
ctx.fillRect(0, 0, width, height);
ctx.globalAlpha = 1.0;
ctx.globalCompositeOperation = 'source-over';
}
// 8. Dust and Scratches
// Scratches
for(let i = 0; i < scratchCount; i++) {
ctx.beginPath();
let sx = Math.random() * width;
let sy = Math.random() * height;
ctx.moveTo(sx, sy);
let ex = sx + (Math.random() - 0.5) * (width * 0.1);
let ey = sy + (Math.random() > 0.5 ? 1 : -1) * (height * 0.4);
ctx.strokeStyle = Math.random() > 0.8 ? 'rgba(230,230,230,0.4)' : 'rgba(10,10,10,0.5)';
ctx.lineWidth = Math.random() * 1.5 + 0.5;
let cp1x = sx + (Math.random()-0.5)*30;
let cp1y = sy + (ey-sy)*0.3;
let cp2x = ex + (Math.random()-0.5)*30;
let cp2y = sy + (ey-sy)*0.7;
ctx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, ex, ey);
ctx.stroke();
}
// Dust particles
for(let i = 0; i < dustCount; i++) {
ctx.beginPath();
let dx = Math.random() * width;
let dy = Math.random() * height;
let dr = Math.random() * 2;
if (Math.random() > 0.95) dr *= 3; // Occasional dirt clump
ctx.arc(dx, dy, dr, 0, Math.PI * 2);
ctx.fillStyle = Math.random() > 0.3 ? `rgba(15,15,15,${Math.random() * 0.8 + 0.2})` : `rgba(220,220,220,${Math.random() * 0.5 + 0.1})`;
ctx.fill();
}
// 9. Messy Plate Collodion Irregular Border
if (borderThickness > 0) {
let bWidth = Math.max(width, height) * borderThickness;
ctx.fillStyle = '#0a0a09';
ctx.fillRect(0, 0, width, bWidth);
ctx.fillRect(0, height - bWidth, width, bWidth);
ctx.fillRect(0, 0, bWidth, height);
ctx.fillRect(width - bWidth, 0, bWidth, height);
if (borderIrregularity > 0) {
let steps = 60;
ctx.beginPath();
for(let i = 0; i <= steps; i++) {
let p = i / steps;
// Top
ctx.arc(p * width, bWidth, Math.random() * bWidth * borderIrregularity, 0, Math.PI);
ctx.fill();
// Bottom
ctx.arc(p * width, height - bWidth, Math.random() * bWidth * borderIrregularity, Math.PI, 0);
ctx.fill();
// Left
ctx.arc(bWidth, p * height, Math.random() * bWidth * borderIrregularity, -Math.PI/2, Math.PI/2);
ctx.fill();
// Right
ctx.arc(width - bWidth, p * height, Math.random() * bWidth * borderIrregularity, Math.PI/2, -Math.PI/2);
ctx.fill();
}
}
}
return canvas;
}
Apply Changes