Please bookmark this page to avoid losing your image tool!

Image Glow Effect Applicator

(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, glowColor = 'rgba(255, 255, 255, 0.7)', glowRadius = 10) {
    // Sanitize glowRadius: ensure it's a non-negative number.
    // Number() converts various types, including strings like "15", to numbers.
    // If conversion results in NaN (e.g., for "abc") or if it's negative, default to 0.
    let numericGlowRadius = Number(glowRadius);
    if (isNaN(numericGlowRadius) || numericGlowRadius < 0) {
        numericGlowRadius = 0;
    }
    // Use this sanitized, non-negative radius for all calculations.
    const actualGlowRadius = numericGlowRadius;

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

    // Determine canvas dimensions. It needs to be large enough to contain the image
    // plus the glow effect extending outwards from the image.
    // The image will be drawn offset by actualGlowRadius from the top-left of the canvas.
    const canvasWidth = originalImg.naturalWidth + actualGlowRadius * 2;
    const canvasHeight = originalImg.naturalHeight + actualGlowRadius * 2;

    canvas.width = canvasWidth;
    canvas.height = canvasHeight;

    // If glowRadius is positive, set up the shadow properties for the glow effect.
    // The shadowColor property accepts CSS color strings, e.g., 'red', '#FF0000', 'rgba(255,0,0,0.5)'.
    // The shadowBlur property dictates how blurred the shadow is. Larger values mean more blur.
    if (actualGlowRadius > 0) {
        ctx.shadowColor = glowColor;
        ctx.shadowBlur = actualGlowRadius;
        
        // shadowOffsetX and shadowOffsetY control the shadow's position relative to the shape.
        // For a centered glow effect, these should be 0. They are 0 by default,
        // but setting them explicitly clarifies the intent.
        ctx.shadowOffsetX = 0;
        ctx.shadowOffsetY = 0;
    }

    // Draw the original image onto the canvas.
    // It's offset by actualGlowRadius in both x and y directions. This provides
    // space for the glow to appear around the image.
    // The canvas shadow properties (if set) will cause a shadow to be rendered
    // simultaneously with the image. The shadow is based on the alpha channel of the
    // image being drawn (i.e., transparent areas of the image won't cast a shadow).
    ctx.drawImage(
        originalImg,
        actualGlowRadius, // x-coordinate of the top-left corner of the image on the canvas
        actualGlowRadius, // y-coordinate of the top-left corner of the image on the canvas
        originalImg.naturalWidth,
        originalImg.naturalHeight
    );

    // The canvas now contains the image with the glow effect applied.
    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 Glow Effect Applicator enhances images by adding a customizable glow effect around the edges. Users can specify the color and radius of the glow to achieve the desired effect, making images visually striking and appealing. This tool is ideal for graphic designers, content creators, and anyone looking to enhance their images for presentations, social media, or artistic projects. By applying a glow effect, users can make their images stand out, draw attention, and add a professional touch to their visual content.

Leave a Reply

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