You can edit the below JavaScript code to customize the image tool.
/**
* Applies an "Elusive Grip" effect to an image, simulating a fleeting, glitched capture.
* This function demonstrates the technique by combining motion ghosting, chromatic aberration,
* and horizontal data-moshing to create an unstable, hard-to-capture aesthetic.
*
* @param {HTMLImageElement} originalImg The original image object.
* @param {number} ghostIntensity The number of ghost images to create for the motion effect. Higher is more intense. Defaults to 8.
* @param {number} glitchIntensity The maximum horizontal pixel offset for the glitch effect. Defaults to 15.
* @param {number} aberrationIntensity The maximum horizontal pixel offset for the color channel separation. Defaults to 5.
* @returns {HTMLCanvasElement} A new canvas element displaying the image with the applied effect.
*/
function processImage(originalImg, ghostIntensity = 8, glitchIntensity = 15, aberrationIntensity = 5) {
// Ensure parameters are valid numbers with fallbacks
ghostIntensity = Number(ghostIntensity) || 8;
glitchIntensity = Number(glitchIntensity) || 15;
aberrationIntensity = Number(aberrationIntensity) || 5;
const canvas = document.createElement('canvas');
// Using { willReadFrequently: true } is a performance hint for browsers for heavy getImageData/putImageData operations
const ctx = canvas.getContext('2d', { willReadFrequently: true });
const w = originalImg.naturalWidth;
const h = originalImg.naturalHeight;
canvas.width = w;
canvas.height = h;
// --- Step 1: Create a "ghosting" or motion blur effect ---
// This simulates a shaky hand or movement during capture.
// We draw the image multiple times with low opacity and random small offsets.
ctx.globalAlpha = 0.15;
for (let i = 0; i < ghostIntensity; i++) {
const offsetX = (Math.random() - 0.5) * ghostIntensity;
const offsetY = (Math.random() - 0.5) * ghostIntensity;
ctx.drawImage(originalImg, offsetX, offsetY, w, h);
}
// --- Step 2: Draw the main, sharp image on top of the ghosting ---
ctx.globalAlpha = 1.0;
ctx.drawImage(originalImg, 0, 0, w, h);
// --- Step 3: Apply horizontal glitch bands ---
// This simulates data corruption or a digital capture error.
const glitchBandMaxHeight = 5;
for (let y = 0; y < h; y++) {
// Randomly decide to start a glitch band at this y-coordinate with a low probability
if (Math.random() > 0.96) {
const bandHeight = Math.ceil(Math.random() * glitchBandMaxHeight);
const sourceY = y;
const sourceHeight = Math.min(bandHeight, h - y);
if (sourceHeight <= 0) continue;
try {
const imageData = ctx.getImageData(0, sourceY, w, sourceHeight);
const offset = (Math.random() - 0.5) * glitchIntensity;
ctx.putImageData(imageData, offset, sourceY);
} catch (e) {
// Ignore cross-origin errors if the image is tainted
console.error("Could not apply glitch effect due to cross-origin policy.", e);
}
y += sourceHeight; // Move past the band we just glitched
}
}
// --- Step 4: Add Chromatic Aberration (Color Channel Splitting) ---
// This mimics lens distortion and enhances the unstable, "elusive" feel.
let baseImageData;
try {
baseImageData = ctx.getImageData(0, 0, w, h);
} catch(e) {
// If getImageData failed above, it will fail here too. Return the canvas as-is.
console.error("Could not apply aberration due to cross-origin policy. Returning intermediate result.", e);
return canvas;
}
ctx.clearRect(0, 0, w, h);
// Create an offscreen canvas for processing color channels efficiently
const tempCanvas = document.createElement('canvas');
tempCanvas.width = w;
tempCanvas.height = h;
const tempCtx = tempCanvas.getContext('2d', { willReadFrequently: true });
ctx.globalCompositeOperation = 'lighter';
// Isolate, shift, and draw the RED channel
tempCtx.putImageData(baseImageData, 0, 0);
tempCtx.globalCompositeOperation = 'multiply';
tempCtx.fillStyle = 'rgb(255, 0, 0)';
tempCtx.fillRect(0, 0, w, h);
const rOffset = (Math.random() - 0.5) * aberrationIntensity;
ctx.drawImage(tempCanvas, rOffset, 0);
// Isolate, shift, and draw the GREEN channel
tempCtx.globalCompositeOperation = 'source-over'; // Reset for source image
tempCtx.clearRect(0, 0, w, h);
tempCtx.putImageData(baseImageData, 0, 0);
tempCtx.globalCompositeOperation = 'multiply';
tempCtx.fillStyle = 'rgb(0, 255, 0)';
tempCtx.fillRect(0, 0, w, h);
const gOffset = (Math.random() - 0.5) * aberrationIntensity;
ctx.drawImage(tempCanvas, gOffset, 0);
// Isolate, shift, and draw the BLUE channel
tempCtx.globalCompositeOperation = 'source-over'; // Reset for source image
tempCtx.clearRect(0, 0, w, h);
tempCtx.putImageData(baseImageData, 0, 0);
tempCtx.globalCompositeOperation = 'multiply';
tempCtx.fillStyle = 'rgb(0, 0, 255)';
tempCtx.fillRect(0, 0, w, h);
const bOffset = (Math.random() - 0.5) * aberrationIntensity;
ctx.drawImage(tempCanvas, bOffset, 0);
// Reset composite operation for the final canvas
ctx.globalCompositeOperation = 'source-over';
return canvas;
}
Free Image Tool Creator
Can't find the image tool you're looking for? Create one based on your own needs now!
The Image Capture Technique Guide tool allows users to apply a unique ‘Elusive Grip’ effect to images, simulating fleeting, glitched captures. This tool creates a distinctive aesthetic by incorporating motion ghosting, chromatic aberration, and horizontal data-moshing. It can be utilized by photographers, graphic designers, and digital artists to produce artistic effects for various projects, including creating abstract pieces, enhancing visuals for social media, or experimenting with design concepts.