Please bookmark this page to avoid losing your image tool!

Movie Studio Of The Year Photo Remover

(Free & Supports Bulk Upload)

Drag & drop your images here or

The result will appear here...
You can edit the below JavaScript code to customize the image tool.
function processImage(originalImg, keyColor = '#00FF00', tolerance = 100, softness = 40) {
    // Create a canvas to process the image
    const canvas = document.createElement('canvas');
    canvas.width = originalImg.width;
    canvas.height = originalImg.height;
    const ctx = canvas.getContext('2d', { willReadFrequently: true });
    
    // Draw the original image onto the canvas
    ctx.drawImage(originalImg, 0, 0);

    // Get the image data for pixel-level manipulation
    const imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
    const data = imgData.data;

    // Use a temporary canvas to resolve the target CSS keyColor to exactly extraction-ready RGB values 
    const tempCanvas = document.createElement('canvas');
    tempCanvas.width = 1;
    tempCanvas.height = 1;
    const tempCtx = tempCanvas.getContext('2d', { willReadFrequently: true });
    tempCtx.fillStyle = keyColor;
    tempCtx.fillRect(0, 0, 1, 1);
    
    // Deconstruct RGB
    const [rKey, gKey, bKey] = tempCtx.getImageData(0, 0, 1, 1).data;

    // Parse numeric limits to handle input robustness
    const tol = Number(tolerance);
    const soft = Number(softness);

    // Iterate through every pixel for "Movie Studio" Chroma Key (Greenscreen) Removal
    for (let i = 0; i < data.length; i += 4) {
        const r = data[i];
        const g = data[i + 1];
        const b = data[i + 2];
        const a = data[i + 3];

        // Skip fully transparent pixels
        if (a === 0) continue;

        // Calculate Euclidean distance mapped in 3D RGB color space
        const distance = Math.sqrt(
            Math.pow(r - rKey, 2) +
            Math.pow(g - gKey, 2) +
            Math.pow(b - bKey, 2)
        );

        // Subtractive color mixing logic
        if (distance < tol) {
            if (distance < tol - soft) {
                // If it squarely falls within the strict tolerance - remove background entirely
                data[i + 3] = 0;
            } else {
                // Anti-aliasing soft edges: transition nicely out of transparency
                // to avoid jagged borders commonly seen in harsh background removers
                const alphaRatio = (distance - (tol - soft)) / soft;
                data[i + 3] = Math.floor(a * alphaRatio);
            }
            
            // Optionally, we can also perform spill suppression on remaining semi-transparent edge pixels 
            // by draining out matching component chroma, but fading transparency suffices mostly.
        }
    }

    // Put the modified image data back
    ctx.putImageData(imgData, 0, 0);
    
    return canvas;
}

Free Image Tool Creator

Can't find the image tool you're looking for?
Create one based on your own needs now!

Description

This tool is designed to remove specific background colors from images using chroma key technology. By selecting a target key color and adjusting tolerance and softness settings, users can isolate a subject and make the surrounding background transparent. This is particularly useful for photographers, digital artists, and video editors who need to extract subjects from green or blue screens to composite them into new environments or create clean assets for graphic design.

Leave a Reply

Your email address will not be published. Required fields are marked *