Please bookmark this page to avoid losing your image tool!

Image Soft Focus 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.
function processImage(originalImg, blurAmount = 5, sharpness = 0.3) {
    // Sanitize blurAmount: must be a non-negative number.
    // If input is invalid (e.g., NaN after Number()), default to 0. Then ensure it's not negative.
    let actualBlurAmount = Number(blurAmount);
    if (isNaN(actualBlurAmount)) {
        actualBlurAmount = 5; // Use default if initial provided value was not a number
    }
    actualBlurAmount = Math.max(0, actualBlurAmount);

    // Sanitize sharpness: must be a number between 0 and 1.
    // If input is invalid, default to 0. Then clamp to [0, 1] range.
    let actualSharpness = Number(sharpness);
    if (isNaN(actualSharpness)) {
        actualSharpness = 0.3; // Use default if initial provided value was not a number
    }
    actualSharpness = Math.max(0, Math.min(1, actualSharpness));

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

    // Use naturalWidth/Height for intrinsic dimensions, fallback to width/height if natural are 0
    // (e.g. for an un-loaded image, though this is best effort for robustness)
    const width = originalImg.naturalWidth || originalImg.width;
    const height = originalImg.naturalHeight || originalImg.height;

    canvas.width = width;
    canvas.height = height;

    // If the image has no dimensions (e.g., not loaded, or it's a 0x0 image),
    // return an empty canvas.
    if (width === 0 || height === 0) {
        // console.warn("Image has zero dimensions or is not loaded. Returning an empty canvas.");
        return canvas;
    }

    // Step 1: Draw the base image, potentially blurred.
    // If 'actualBlurAmount' is 0, this draws the original image sharply (filter set to 'none').
    if (actualBlurAmount > 0) {
        ctx.filter = `blur(${actualBlurAmount}px)`;
    } else {
        ctx.filter = 'none'; // Ensure no blur if blurAmount is zero
    }
    ctx.drawImage(originalImg, 0, 0, width, height);

    // Reset filter: ensures the next draw operation (the sharpness layer) is not affected by the blur.
    ctx.filter = 'none';

    // Step 2: Overlay the original (sharp) image with 'actualSharpness' opacity.
    // This step blends the sharp details back into the image.
    // - If 'actualSharpness' is 0, this draw operation is effectively skipped (or draws fully transparent),
    //   leaving the result of Step 1 (the blurred image, or original if blurAmount was 0).
    // - If 'actualSharpness' is 1, this draws the original image fully opaquely,
    //   effectively replacing the blurred version from Step 1 (resulting in the original image).
    // - For values between 0 and 1, it blends the sharp image with the blurred one.
    
    // Only draw the sharpness layer if it contributes (i.e., sharpness > 0).
    // If actualSharpness is 0, the blurred image from Step 1 is the final result.
    if (actualSharpness > 0) {
        ctx.globalAlpha = actualSharpness;
        ctx.drawImage(originalImg, 0, 0, width, height);
        ctx.globalAlpha = 1.0; // Reset globalAlpha to its default (1.0) for good practice.
    }
    // If actualSharpness was 0, the canvas correctly contains the image from Step 1.
    // If actualBlurAmount was also 0, this means the original image is on the canvas.
    // If actualBlurAmount > 0 and actualSharpness = 0, this means the blurred image is on the canvas.
    // Both are correct interpretations of the parameters for "maximum softness".

    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 Soft Focus Filter Effect Tool allows users to apply a soft focus effect to images. By adjusting the blur amount and sharpness, you can create a dreamy, softer look that can enhance portraits, give a gentle atmosphere to landscape photography, or produce artistic effects for various visual media. This tool is especially useful for photographers and graphic designers looking to modify images for marketing materials, social media posts, or personal projects.

Leave a Reply

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

Other Image Tools:

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

Image Cinestill 800T Filter Effect Tool

Image Glimmer Glass Filter Effect Tool

Image Star Filter Effect Tool

Image Kodak Portra 400 Film Filter Effect

Image Fujifilm Superia Filter Effect Tool

Image Tilt-Shift Lens Filter Effect Tool

Image Graduated Neutral Density Filter Effect Tool

Image Diana Camera Filter Effect Tool

Image 35mm Film Camera Filter Effect Tool

Image Pro-Mist Filter Effect Application

Image Cross-Processed Slide Film Filter Effect Application

Image Pull-Processed Film Filter Effect Tool

Image Infrared Filter Effect Application

Image Ilford Delta 3200 Filter Effect Application

Image Cooling Filter Effect Tool

Image Fujifilm Instax Filter Effect Creator

Image Black And White Effect With Orange Filter

Image Kodak Tri-X Filter Effect Tool

Image Ilford HP5 Plus Filter Effect Application

Image Orchestra Seating Filter Effect

Image Braille Text Filter Effect

Image Missile Trajectory Filter Effect Tool

Image Ski Trail Filter Effect Tool

Image Secret Code Filter Effect Tool

Image Lock And Key Filter Effect Tool

Image Compass Rose Filter Effect

Image Prison Bar Filter Effect

See All →