You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, midgeIntensity = "50", contrastLevel = "1.2", tintColor = "#ffb347") {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const width = originalImg.width;
const height = originalImg.height;
canvas.width = width;
canvas.height = height;
// Draw the original image onto the canvas
ctx.drawImage(originalImg, 0, 0);
const imgData = ctx.getImageData(0, 0, width, height);
const data = imgData.data;
// Parse parameters
const noiseLevel = parseFloat(midgeIntensity) || 50;
const contrast = parseFloat(contrastLevel) || 1.2;
// Parse tint color safely
let tr = 255, tg = 179, tb = 71;
let hex = String(tintColor).trim().replace(/^#/, '');
if (hex.length === 3) {
hex = hex.split('').map(x => x + x).join('');
}
if (hex.length === 6) {
tr = parseInt(hex.substring(0, 2), 16);
tg = parseInt(hex.substring(2, 4), 16);
tb = parseInt(hex.substring(4, 6), 16);
}
if (isNaN(tr) || isNaN(tg) || isNaN(tb)) {
tr = 255; tg = 179; tb = 71; // default to a warm vintage tint
}
const intercept = 128 * (1 - contrast);
// Apply the Midge Major effect at the pixel level
for (let i = 0; i < data.length; i += 4) {
let r = data[i];
let g = data[i + 1];
let b = data[i + 2];
// 1. Contrast Boost
r = r * contrast + intercept;
g = g * contrast + intercept;
b = b * contrast + intercept;
// 2. Multiply Tint
r = (r * tr) / 255;
g = (g * tg) / 255;
b = (b * tb) / 255;
// 3. "Midge" Noise Synthesis
// Produces a crawling gritty effect across the image
const noise = (Math.random() - 0.5) * noiseLevel;
r += noise;
g += noise;
b += noise;
// Clamp values
data[i] = Math.max(0, Math.min(255, r));
data[i + 1] = Math.max(0, Math.min(255, g));
data[i + 2] = Math.max(0, Math.min(255, b));
// Alpha (data[i + 3]) is left untouched
}
ctx.putImageData(imgData, 0, 0);
// 4. "Major" Vignette Overlay
// Gives the final output a deep cinematic focal pull
const cx = width / 2;
const cy = height / 2;
const radius = Math.max(width, height) / 1.5;
const gradient = ctx.createRadialGradient(cx, cy, radius * 0.3, cx, cy, radius);
gradient.addColorStop(0, 'rgba(0, 0, 0, 0)');
gradient.addColorStop(1, 'rgba(15, 15, 20, 0.7)');
ctx.globalCompositeOperation = 'multiply';
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, width, height);
// Reset composite operation
ctx.globalCompositeOperation = 'source-over';
return canvas;
}
Apply Changes