Please bookmark this page to avoid losing your image tool!

Image Reverse Graduated ND 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, strength = 0.5, horizonPosition = 0.5, gradientHeight = 0.3) {
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');

    // Use naturalWidth/Height for HTMLImageElement for intrinsic size, fallback to width/height for other image sources
    const imgWidth = originalImg.naturalWidth || originalImg.width;
    const imgHeight = originalImg.naturalHeight || originalImg.height;

    canvas.width = imgWidth;
    canvas.height = imgHeight;

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

    // Clamp parameters to ensure they are within expected ranges [0, 1]
    strength = Math.max(0, Math.min(1, strength));
    horizonPosition = Math.max(0, Math.min(1, horizonPosition));
    gradientHeight = Math.max(0, Math.min(1, gradientHeight));

    // Calculate absolute pixel values for gradient geometry
    
    // maxStrengthY is the Y-coordinate where the darkening effect is strongest.
    // This corresponds to the "horizon line" for the filter effect.
    // At this line, the gradient reaches its full `strength` alpha.
    const maxStrengthY = imgHeight * horizonPosition;
    
    // gradientEffectiveHeight is the actual height in pixels of the gradient transition area.
    // This is the distance over which the filter effect fades from transparent to full strength.
    const gradientEffectiveHeight = imgHeight * gradientHeight;

    // If gradientEffectiveHeight is zero or negative (e.g., if gradientHeight parameter is 0),
    // the fillRect operation below will have zero or negative height.
    // According to canvas specs, this means nothing will be drawn, which is the correct behavior
    // for a gradient defined over a zero-height region. No special handling is needed.
    
    // gradientTopY is the Y-coordinate where the gradient effect begins.
    // At this line, the filter effect is fully transparent (alpha = 0).
    // The gradient progresses from transparent at gradientTopY to `strength` alpha at maxStrengthY.
    const gradientTopY = maxStrengthY - gradientEffectiveHeight;

    // Create a linear gradient object.
    // The gradient is vertical. Its coordinates are specified in the canvas's coordinate space.
    // It starts at (any X-coordinate, gradientTopY) and ends at (any X-coordinate, maxStrengthY).
    const grad = ctx.createLinearGradient(0, gradientTopY, 0, maxStrengthY);

    // Add color stops to define the gradient's color and alpha transition.
    // Stop 0: At the beginning of the gradient (y = gradientTopY), the overlay color is fully transparent black.
    grad.addColorStop(0, 'rgba(0,0,0,0)');
    // Stop 1: At the end of the gradient (y = maxStrengthY), the overlay color is black with an alpha value equal to `strength`.
    grad.addColorStop(1, `rgba(0,0,0,${strength})`);

    // Set the canvas fill style to the created gradient.
    ctx.fillStyle = grad;
    
    // Apply the gradient effect by filling a rectangle.
    // This rectangle starts at X=0, Y=gradientTopY.
    // Its width is the full image width.
    // Its height is `gradientEffectiveHeight`, so it covers the region from `gradientTopY` to `maxStrengthY`.
    // The Canvas API correctly handles cases where part of this rectangle (e.g., if gradientTopY is negative)
    // is outside the canvas boundaries; only the visible portion will be rendered.
    // The default `globalCompositeOperation` is 'source-over', which means the semi-transparent
    // gradient color will be drawn on top of the original image, achieving the desired blending.
    ctx.fillRect(0, gradientTopY, imgWidth, gradientEffectiveHeight);

    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 Reverse Graduated ND Filter Effect Tool allows users to apply a reverse graduated neutral density filter effect to their images. This tool is useful for photographers and graphic designers who want to enhance landscapes or scenes where the horizon is bright compared to the foreground. By adjusting parameters such as strength, horizon position, and gradient height, users can control the intensity and position of the darkening effect, helping to balance exposure across different parts of the image.

Leave a Reply

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

Other Image Tools:

Image Kaleidoscope Filter Effect Tool

Image Platinum Palladium Print Filter Effect

Image Light Leak Filter Effect Tool

Image Moire Pattern Filter Effect Tool

Image Pull Processing Filter Effect Tool

Photo Ambrotype Filter Effect Tool

Image Cross-Screen Star Filter Effect Tool

Image Tiffen Ultra Contrast Filter Effect Application

Photo Telephoto Lens Compression Filter Effect Tool

Image Leica M6 Camera Render Filter Effect

Image Cokin Sunset Filter Effect Application

Image CineScope Aspect Ratio Filter Effect Tool

Image Ilford FP4 Plus Filter Effect Tool

Image Infrared 850nm Filter Effect Tool

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

See All →