Please bookmark this page to avoid losing your image tool!

Image Pinhole Solargraphy Effect Creator

(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, sunColor = "255,255,150", shadowColor = "20,20,70", threshold = 128, blurRadius = 0) {
    // 1. Parameter parsing and sanitization
    const parseColorComponent = (strVal, defaultVal) => {
        const num = parseInt(strVal, 10);
        if (isNaN(num)) {
            return defaultVal;
        }
        return Math.max(0, Math.min(255, num));
    };

    const parseColorString = (colorStr, defaultR, defaultG, defaultB) => {
        const parts = colorStr.split(',');
        if (parts.length === 3) {
            return [
                parseColorComponent(parts[0], defaultR),
                parseColorComponent(parts[1], defaultG),
                parseColorComponent(parts[2], defaultB)
            ];
        }
        return [defaultR, defaultG, defaultB]; // Fallback to defaults
    };

    const sunRGB = parseColorString(sunColor, 255, 255, 150);
    const shadowRGB = parseColorString(shadowColor, 20, 20, 70);

    const validThreshold = Math.max(0, Math.min(255, Number(threshold) || 0));
    const validBlurRadius = Math.max(0, Number(blurRadius) || 0);

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

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

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

    // If image dimensions are zero, return an empty canvas
    if (imgWidth === 0 || imgHeight === 0) {
        console.warn("Image dimensions are zero. Returning an empty canvas.");
        return canvas;
    }
    
    // 3. Draw image, applying blur if specified (simulating pinhole softness)
    if (validBlurRadius > 0) {
        ctx.filter = `blur(${validBlurRadius}px)`;
        ctx.drawImage(originalImg, 0, 0, imgWidth, imgHeight);
        ctx.filter = 'none'; // Reset filter immediately after use
    } else {
        ctx.drawImage(originalImg, 0, 0, imgWidth, imgHeight);
    }
    
    // 4. Get image data
    let imageData;
    try {
        imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
    } catch (e) {
        // This can happen due to tainted canvas if image is cross-origin
        // and server doesn't allow CORS, or other canvas errors.
        console.error("Could not get image data:", e);
        // Create an error message on the canvas
        ctx.clearRect(0, 0, canvas.width, canvas.height); // Clear previous drawing
        ctx.font = "16px Arial";
        ctx.fillStyle = "red";
        ctx.textAlign = "center";
        ctx.textBaseline = "middle";
        ctx.fillText("Error: Could not process image.", canvas.width / 2, canvas.height / 2);
        if (e.name === 'SecurityError') {
             ctx.fillText("May be a cross-origin image issue.", canvas.width / 2, canvas.height / 2 + 20);
        }
        return canvas;
    }
    
    const data = imageData.data;

    // 5. Pixel manipulation for Solargraphy effect
    // This creates a high-contrast, two-tone effect based on luminance.
    for (let i = 0; i < data.length; i += 4) {
        const r = data[i];
        const g = data[i + 1];
        const b = data[i + 2];
        // Alpha (data[i+3]) is preserved

        // Calculate luminance from (potentially blurred) pixel
        const luminance = 0.299 * r + 0.587 * g + 0.114 * b;

        if (luminance >= validThreshold) {
            data[i] = sunRGB[0];     // Apply sun color to bright areas
            data[i + 1] = sunRGB[1];
            data[i + 2] = sunRGB[2];
        } else {
            data[i] = shadowRGB[0];  // Apply shadow color to dark areas
            data[i + 1] = shadowRGB[1];
            data[i + 2] = shadowRGB[2];
        }
    }

    // 6. Put modified image data back
    ctx.putImageData(imageData, 0, 0);

    // 7. Return 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 Image Pinhole Solargraphy Effect Creator is an online tool that allows users to transform their images into unique artworks with a pinhole solargraphy effect. This effect simulates a high-contrast, two-tone image based on the luminance of the pixels, enabling users to create visually striking representations of their photos. The tool provides options to customize the colors for bright and dark areas, adjust the threshold for luminance, and apply a blur effect to mimic the characteristics of pinhole photography. This tool is particularly useful for artists, photographers, and hobbyists looking to experiment with creative photo effects or for educational purposes in understanding artistic interpretations of light and shadow.

Leave a Reply

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

Other Image Tools:

Image Kodak Vision3 500T Motion Picture Film Effect Simulator

Image Soft Focus Filter Effect for Nikon Nikkor

Image Bergger Pancro 400 Film Filter Effect Tool

Image Agfa Optima Filter Effect Application

Image Technicolor 3-Strip Process Filter Effect

Image Cyanotype Process Filter Effect

Image Black and White with Orange #21 Filter Effect Tool

Image Bleach Bypass Effect Filter

Image IMAX Camera Filter Effect Tool

Image Super 8 Film Filter Effect Tool

Image Anamorphic Lens Flare Filter Effect Tool

Image Prism Photography Filter Effect Tool

Image Freelensing Effect Creator

Image Tiffen Glimmerglass Filter Effect Tool

Image Mamiya RZ67 Medium Format Filter Effect Tool

Image Wet Plate Collodion Filter Effect Tool

Image Ilford Pan F Plus 50 Filter Effect Tool

Image X-ray Photography Filter Effect Tool

Image Radial Graduated Filter Effect Tool

Image Lee 80A Cooling Filter Effect Application

Image Autochrome Lumière Filter Effect Tool

Photo Infrared 720nm Filter Effect Tool

Image 10-Stop ND Filter Effect Tool

Photo Full Spectrum Filter Effect Tool

Image Motion Blur Filter Effect Tool

Image Panavision Film Look Filter Effect Tool

Image Rolleiflex TLR Camera Filter Effect Tool

Image Lee 85B Warming Filter Effect Application

Image Tiffen Black Pro-Mist Filter Effect Tool

Image Fomapan 100 Filter Effect Application

Image Lens Flare Filter Effect Tool

Image Ilford XP2 Super Filter Effect Application

Image Cinemascope Filter Effect Applicator

Image Dubblefilm Solar Filter Effect Application

Image Night Vision Filter Effect Tool

Image Tintype Filter Effect Application

See All →