Please bookmark this page to avoid losing your image tool!

Image Infrared 850nm Filter Effect Tool

(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.
async function processImage(originalImg, rCoeff = 0.2, gCoeff = 1.2, bCoeff = -0.4) {
    const canvas = document.createElement('canvas');
    
    // Ensure the image is fully loaded to get correct dimensions
    // This might not be strictly necessary if originalImg is guaranteed to be loaded,
    // but it's a good practice.
    if (!originalImg.complete || originalImg.naturalWidth === 0) {
        // Wait for the image to load if it's not already
        // This part assumes originalImg is an HTMLImageElement that might still be loading.
        // If originalImg comes from another source (e.g. another canvas), this await might not be needed
        // or might need different handling depending on how originalImg is obtained.
        await new Promise((resolve, reject) => {
            originalImg.onload = resolve;
            originalImg.onerror = () => {
                console.error("Image failed to load.");
                // Set canvas to a minimal size if image fails to load
                canvas.width = 1;
                canvas.height = 1;
                reject(new Error("Image load error"));
            };
            // If src is already set and it failed, onerror might have already fired.
            // If src is not set, this won't trigger loading.
            // This assumes src is set and loading, or already loaded.
        }).catch(e => {
            // If image loading fails, we can'g proceed with processing.
            // Return the (possibly tiny) canvas.
             return canvas;
        });
    }

    const width = originalImg.naturalWidth || originalImg.width;
    const height = originalImg.naturalHeight || originalImg.height;

    if (width === 0 || height === 0) {
        console.error("Image has zero dimensions even after attempting to load.");
        canvas.width = 1; 
        canvas.height = 1;
        return canvas; 
    }

    canvas.width = width;
    canvas.height = height;
    
    const ctx = canvas.getContext('2d');
    if (!ctx) {
        console.error("Could not get 2D rendering context.");
        // Return an empty canvas if context cannot be obtained
        return canvas; 
    }

    try {
        // Draw the original image onto the canvas
        ctx.drawImage(originalImg, 0, 0, canvas.width, canvas.height);
    } catch (e) {
        console.error("Error drawing image to canvas:", e);
        // This can happen if originalImg is not a valid image source
        // Return the canvas, which might be blank or partially drawn
        return canvas;
    }


    let imageData;
    try {
        // Get the image data from the canvas
        imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
    } catch (e) {
        // This error typically occurs if the image is cross-origin and the canvas becomes tainted.
        console.error("Could not get image data (possibly due to CORS policy):", e);
        // One strategy is to return the canvas with the original image drawn,
        // as processing is not possible.
        // Or, if the environment allows, one might try to re-fetch the image with crossOrigin="anonymous".
        // For this function, we'll return the canvas as-is.
        return canvas; 
    }
    
    const data = imageData.data; // This is a Uint8ClampedArray

    // The parameters rCoeff, gCoeff, bCoeff define the specific "850nm" look.
    // These defaults are chosen to simulate the common characteristics of 850nm IR photography:
    // - Green foliage becomes very bright (Wood Effect).
    // - Blue skies and water become very dark.
    // - The image is monochrome.

    for (let i = 0; i < data.length; i += 4) {
        const r = data[i];     // Red channel
        const g = data[i + 1]; // Green channel
        const b = data[i + 2]; // Blue channel
        // data[i + 3] is the Alpha channel, we'll leave it unchanged.

        // Calculate the monochrome infrared intensity based on the coefficients
        let irIntensity = (r * rCoeff) + (g * gCoeff) + (b * bCoeff);

        // Clamp the intensity value to the valid 0-255 range
        irIntensity = Math.max(0, Math.min(255, irIntensity));
        
        // Apply the new intensity to the R, G, and B channels
        data[i] = irIntensity;     // New Red
        data[i + 1] = irIntensity; // New Green
        data[i + 2] = irIntensity; // New Blue
    }

    // Put the modified image 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 Infrared 850nm Filter Effect Tool allows users to simulate the effects of infrared photography by applying an 850nm infrared filter effect to their images. This tool can transform photos by enhancing the brightness of green foliage and darkening blue skies, creating striking monochrome images that capture the unique characteristics of infrared imagery. It can be particularly useful for photographers looking to create artistic representations of landscapes, for environmental studies analyzing vegetation health, or for anyone interested in experimenting with creative photography techniques.

Leave a Reply

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

Other Image Tools:

Image Pentax 67 Medium Format Filter Effect Tool

Image ARRI Alexa Cinema Camera Filter Effect Enhancer

Image Cinestill 50D Filter Effect Application

Image Kodachrome 64 Filter Effect Tool

Photo Lomography Berlin Kino Filter Effect Tool

Image Fujifilm Neopan Filter Effect Tool

Image Polaroid Instant Film Filter Effect Tool

Image Holga Camera Filter Effect Tool

Image Fisheye Lens Distortion Filter Effect Tool

Image Kodak Gold 200 Film Filter Effect Tool

Photo Macro Filter Effect Tool

Image Neutral Density Filter Effect Tool

Image Green Filter Black And White Effect Tool

Image Large Format Film Filter Effect Creator

Image Pinhole Camera Filter Effect Tool

Image Warming Filter Effect Tool

Image Fujifilm Pro 400H Filter Effect Application

Image Diffusion Filter Effect Tool

Image Push-Processed Film Filter Effect Tool

Image Color Temperature Orange Filter Effect Tool

Image Kodak Ektar 100 Film Filter Effect

Image Yellow Filter Black And White Effect Tool

Image Expired Film Filter Effect Tool

Image Circular Polarizer Filter Effect Tool

Image Lomography Purple Filter Effect Tool

Image Split Field Filter Effect Tool

Image Soft Focus Filter Effect Tool

Image Medium Format Film Filter Effect

Image Wide-Angle Lens Perspective Filter Effect Tool

Olympus OM-1 Photo Filter Effect Tool

Image Fujifilm Velvia Filter Effect Tool

Image Lensbaby Selective Focus Filter Effect Tool

Image Color Temperature Blue Filter Effect Tool

Image UV Filter Effect Tool

Image Red Filter Black And White Effect Tool

Image Redscale Film Filter Effect

See All →