Please bookmark this page to avoid losing your image tool!

Photo Minimalist Mood 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, saturation = 30, contrast = 120, brightness = 100, moodColor = "none", moodIntensity = 0.15) {
    // Ensure numeric parameters are within reasonable bounds.
    // CSS filters are generally forgiving, but this adds robustness.
    saturation = Math.max(0, saturation); // Percentage, typically 0-200+
    contrast = Math.max(0, contrast);   // Percentage, typically 0-200+
    brightness = Math.max(0, brightness); // Percentage, typically 0-200+
    moodIntensity = Math.max(0, Math.min(1, moodIntensity)); // Opacity, 0-1

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

    // Determine image dimensions. originalImg assumed to be a loaded HTMLImageElement.
    const imgWidth = originalImg.naturalWidth || originalImg.width;
    const imgHeight = originalImg.naturalHeight || originalImg.height;

    // Handle cases where image might not be loaded or has no dimensions
    if (imgWidth === 0 || imgHeight === 0) {
        console.error("Image has not loaded or has zero dimensions.");
        // Return a minimal canvas to avoid further errors downstream
        canvas.width = 1;
        canvas.height = 1;
        ctx.fillStyle = 'red'; // Indicate error
        ctx.fillRect(0,0,1,1);
        return canvas;
    }

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

    // 1. Apply base image adjustments (saturation, contrast, brightness)
    // These CSS-like filters apply to subsequent drawing operations on the context.
    let filterString = '';
    filterString += `saturate(${saturation}%) `;
    filterString += `contrast(${contrast}%) `;
    filterString += `brightness(${brightness}%)`;
    ctx.filter = filterString;

    // Draw the original image onto the canvas. It will be drawn with the filters applied.
    ctx.drawImage(originalImg, 0, 0, canvas.width, canvas.height);

    // 2. Apply mood color tint if specified
    // Check if moodColor is a valid string, not "none", not empty, and intensity is positive.
    if (moodColor && typeof moodColor === 'string' && moodColor.toLowerCase() !== "none" && moodColor.trim() !== "" && moodIntensity > 0) {
        // Reset the ctx.filter. We don't want the mood color rectangle itself
        // to be affected by the saturation/contrast/brightness filters.
        // The mood color should be pure and then blended onto the already-filtered image.
        ctx.filter = 'none';

        // Set the global composite operation for blending the mood color.
        // 'color': Preserves the luma of the destination (filtered image) and
        // adopts the hue and saturation of the source (mood color).
        // This is very effective for tinting.
        ctx.globalCompositeOperation = 'color';

        // Set the opacity for the mood color layer. This controls the strength of the tint.
        ctx.globalAlpha = moodIntensity;

        // Set the fill style to the specified mood color.
        ctx.fillStyle = moodColor;

        // Draw the mood color rectangle over the entire canvas.
        ctx.fillRect(0, 0, canvas.width, canvas.height);

        // Reset globalAlpha and globalCompositeOperation to their default values.
        // This is good practice if the context were to be used for further drawing,
        // though not strictly necessary here as we are about to return the canvas.
        ctx.globalAlpha = 1.0;
        ctx.globalCompositeOperation = 'source-over';
    }
    
    // Optionally, reset the filter on the context if it were to be used further.
    // ctx.filter = 'none'; // Not strictly needed as we return the canvas.

    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 Photo Minimalist Mood Filter tool allows users to enhance their images by adjusting saturation, contrast, and brightness, while also applying a mood color filter to create a specific ambiance. This tool can be useful for photographers and graphic designers looking to create visually appealing images for social media, websites, or personal projects. By customizing the mood of the photo, users can effectively convey emotions or themes in their visuals.

Leave a Reply

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