Please bookmark this page to avoid losing your image tool!

Image Bleach Bypass Effect Filter

(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, strength = 1.0) {
    // Parse and clamp the strength parameter
    // strength parameter controls the intensity of the bleach bypass effect.
    // 0.0 means no effect (original image), 1.0 means full effect.
    let effectStrength = parseFloat(strength);
    if (isNaN(effectStrength)) {
        effectStrength = 1.0; // Default to full strength if input is not a valid number
    }
    effectStrength = Math.max(0.0, Math.min(1.0, effectStrength)); // Clamp to [0, 1] range

    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');

    // Use naturalWidth and naturalHeight to get the original image dimensions
    // This is important if the img element's width/height attributes are scaled
    canvas.width = originalImg.naturalWidth || originalImg.width;
    canvas.height = originalImg.naturalHeight || originalImg.height;

    // Draw the original image onto the canvas
    ctx.drawImage(originalImg, 0, 0, canvas.width, canvas.height);

    // If effectStrength is 0, no processing is needed.
    // The canvas already contains the original image.
    if (effectStrength === 0) {
        return canvas;
    }

    const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
    const data = imageData.data; // This is a Uint8ClampedArray
    const len = data.length;

    // Helper function for the Overlay blend mode component.
    // Overlay blend mode is commonly used to simulate bleach bypass.
    // It blends the original image (backdrop) with its desaturated version (source).
    // backdropChannelNorm: Normalized value of a color channel from the original image.
    // sourceChannelNorm: Normalized grayscale value of the pixel (serves as the source).
    const applyOverlayComponent = (backdropChannelNorm, sourceChannelNorm) => {
        if (backdropChannelNorm < 0.5) {
            return 2 * backdropChannelNorm * sourceChannelNorm;
        } else {
            return 1 - 2 * (1 - backdropChannelNorm) * (1 - sourceChannelNorm);
        }
    };

    // Iterate over each pixel (RGBA components)
    for (let i = 0; i < len; i += 4) {
        const rOrig = data[i];     // Original Red
        const gOrig = data[i+1];   // Original Green
        const bOrig = data[i+2];   // Original Blue
        // Alpha (data[i+3]) is preserved

        // 1. Calculate luminance (grayscale value) of the current pixel.
        // Using Rec.709 luma coefficients (standard for HDTV, widely used).
        // L = 0.2126*R + 0.7152*G + 0.0722*B
        const luminance = (0.2126 * rOrig + 0.7152 * gOrig + 0.0722 * bOrig); // Range 0-255
        const grayNorm = luminance / 255.0; // Normalized luminance for blending [0,1]

        // 2. Normalize original color channels to [0,1] for blending
        const rOrigNorm = rOrig / 255.0;
        const gOrigNorm = gOrig / 255.0;
        const bOrigNorm = bOrig / 255.0;

        // 3. Apply Overlay blend for each color channel.
        // The backdrop is the original color channel, the source is the normalized grayscale value.
        let rProcessedNorm = applyOverlayComponent(rOrigNorm, grayNorm);
        let gProcessedNorm = applyOverlayComponent(gOrigNorm, grayNorm);
        let bProcessedNorm = applyOverlayComponent(bOrigNorm, grayNorm);
        
        // 4. Clamp processed normalized values to [0,1].
        // This is a safeguard for potential floating point inaccuracies,
        // though Overlay blend itself mathematically stays within [0,1] if inputs are in [0,1].
        rProcessedNorm = Math.max(0.0, Math.min(1.0, rProcessedNorm));
        gProcessedNorm = Math.max(0.0, Math.min(1.0, gProcessedNorm));
        bProcessedNorm = Math.max(0.0, Math.min(1.0, bProcessedNorm));

        // 5. Convert processed normalized color channels back to 0-255 range
        const rProcessed = rProcessedNorm * 255;
        const gProcessed = gProcessedNorm * 255;
        const bProcessed = bProcessedNorm * 255;

        // 6. Linearly interpolate between original pixel and processed pixel based on effectStrength.
        // finalValue = (1 - strength) * originalValue + strength * processedValue
        data[i]   = (1 - effectStrength) * rOrig + effectStrength * rProcessed;
        data[i+1] = (1 - effectStrength) * gOrig + effectStrength * gProcessed;
        data[i+2] = (1 - effectStrength) * bOrig + effectStrength * bProcessed;
        // Alpha channel (data[i+3]) remains unchanged.
    }

    // Put the modified pixel data back onto the canvas
    ctx.putImageData(imageData, 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

The Image Bleach Bypass Effect Filter is a photo editing tool that allows users to apply a visually striking bleach bypass effect to their images. This effect enhances contrast and desaturates colors, making images appear more dramatic and stylized. Users can control the intensity of the effect, ranging from none to full strength, enabling customization for various artistic preferences. This tool is particularly useful for photographers, graphic designers, and social media enthusiasts looking to create unique aesthetic styles for their images, whether for personal projects, marketing materials, or online portfolios.

Leave a Reply

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

Other Image Tools:

Image IMAX Camera Filter Effect Tool

Image Super 8 Film Filter Effect Tool

Image Anamorphic Lens Flare Filter Effect Tool

Image Prism Photography Filter Effect Tool

Image Freelensing Effect Creator

Image Tiffen Glimmerglass Filter Effect Tool

Image Mamiya RZ67 Medium Format Filter Effect Tool

Image Wet Plate Collodion Filter Effect Tool

Image Ilford Pan F Plus 50 Filter Effect Tool

Image X-ray Photography Filter Effect Tool

Image Radial Graduated Filter Effect Tool

Image Lee 80A Cooling Filter Effect Application

Image Autochrome Lumière Filter Effect Tool

Photo Infrared 720nm Filter Effect Tool

Image 10-Stop ND Filter Effect Tool

Photo Full Spectrum Filter Effect Tool

Image Motion Blur Filter Effect Tool

Image Panavision Film Look Filter Effect Tool

Image Rolleiflex TLR Camera Filter Effect Tool

Image Lee 85B Warming Filter Effect Application

Image Tiffen Black Pro-Mist Filter Effect Tool

Image Fomapan 100 Filter Effect Application

Image Lens Flare Filter Effect Tool

Image Ilford XP2 Super Filter Effect Application

Image Cinemascope Filter Effect Applicator

Image Dubblefilm Solar Filter Effect Application

Image Night Vision Filter Effect Tool

Image Tintype Filter Effect Application

Image Color Graduated Filter Effect Tool

Image Agfa Vista Filter Effect Application

Image Schneider Hollywood Black Magic Filter Effect Tool

Image TMax 400 Filter Effect Tool

Image Double Exposure Filter Effect Tool

Image Fujichrome Velvia 50 Filter Effect Application

Image Revolog Texture Film Filter Effect Tool

Image Lomography Metropolis Filter Effect Application

See All →