You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, invertPercent = 100, hueRotateDeg = 0, saturationPercent = 250, contrastPercent = 150, rgbSplitDistance = 3, mirrorMode = 'none') {
// Parse and sanitize parameters
invertPercent = Number(invertPercent);
hueRotateDeg = Number(hueRotateDeg);
saturationPercent = Number(saturationPercent);
contrastPercent = Number(contrastPercent);
rgbSplitDistance = Math.floor(Number(rgbSplitDistance));
// Normalize mirrorMode parameter
mirrorMode = String(mirrorMode).trim().toLowerCase();
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 primary effect via Canvas filter.
// The "Major" effect typically relies tightly on intense color inversion, boosted contrast, and adjusted saturation levels.
ctx.filter = `invert(${invertPercent}%) hue-rotate(${hueRotateDeg}deg) saturate(${saturationPercent}%) contrast(${contrastPercent}%)`;
ctx.drawImage(originalImg, 0, 0);
// Reset filter for subsequent operations
ctx.filter = 'none';
// Apply Chromatic Aberration / RGB Split, which is highly common in "HD" YTPMV/Meme visual effects
if (rgbSplitDistance > 0) {
const imageData = ctx.getImageData(0, 0, width, height);
const data = imageData.data;
const outData = new Uint8ClampedArray(data);
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
const i = (y * width + x) * 4;
// Shift Red Channel Left
const shiftRedX = Math.min(width - 1, Math.max(0, x - rgbSplitDistance));
const idxRed = (y * width + shiftRedX) * 4;
// Shift Blue Channel Right
const shiftBlueX = Math.min(width - 1, Math.max(0, x + rgbSplitDistance));
const idxBlue = (y * width + shiftBlueX) * 4;
outData[i] = data[idxRed]; // Red channel shifted
outData[i + 1] = data[i + 1]; // Green channel neutral (untouched)
outData[i + 2] = data[idxBlue + 2]; // Blue channel shifted
outData[i + 3] = data[i + 3]; // Alpha neutral
}
}
imageData.data.set(outData);
ctx.putImageData(imageData, 0, 0);
}
// Apply Mirroring Effects (Also prominent in similar generators)
if (mirrorMode === 'left-to-right' || mirrorMode === 'right-to-left' || mirrorMode === 'top-to-bottom' || mirrorMode === 'bottom-to-top') {
const tempCanvas = document.createElement('canvas');
tempCanvas.width = width;
tempCanvas.height = height;
const tCtx = tempCanvas.getContext('2d');
if (mirrorMode === 'left-to-right' || mirrorMode === 'right-to-left') {
tCtx.translate(width, 0);
tCtx.scale(-1, 1);
tCtx.drawImage(canvas, 0, 0);
if (mirrorMode === 'left-to-right') {
// Takes the mirrored left side onto the right side
ctx.drawImage(tempCanvas, width / 2, 0, width / 2, height, width / 2, 0, Math.ceil(width / 2), height);
} else if (mirrorMode === 'right-to-left') {
// Takes the mirrored right side onto the left side
ctx.drawImage(tempCanvas, 0, 0, Math.ceil(width / 2), height, 0, 0, Math.ceil(width / 2), height);
}
} else if (mirrorMode === 'top-to-bottom' || mirrorMode === 'bottom-to-top') {
tCtx.translate(0, height);
tCtx.scale(1, -1);
tCtx.drawImage(canvas, 0, 0);
if (mirrorMode === 'top-to-bottom') {
ctx.drawImage(tempCanvas, 0, height / 2, width, height / 2, 0, height / 2, width, Math.ceil(height / 2));
} else if (mirrorMode === 'bottom-to-top') {
ctx.drawImage(tempCanvas, 0, 0, width, height / 2, 0, 0, width, Math.ceil(height / 2));
}
}
}
return canvas;
}
Apply Changes