Please bookmark this page to avoid losing your image tool!

Image Solar Panel 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, gridSize = 30, gridColor = 'rgba(0, 0, 0, 0.3)', gridLineWidth = 1, redFactor = 0.3, greenFactor = 0.5, blueChannelFactor = 0.8, blueBoost = 50) {
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');

    // Use natural dimensions of the image to ensure we are working with the original resolution
    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);

    // Get image data if possible (might fail due to CORS for cross-origin images)
    let imageData;
    try {
        imageData = ctx.getImageData(0, 0, imgWidth, imgHeight);
    } catch (e) {
        console.error("Error getting imageData for processing: ", e);
        // If we can't get image data, we can't apply the pixel-level filter.
        // We'll return the canvas with the original image drawn.
        // The grid (if enabled) can still be drawn on top.
    }

    if (imageData) {
        const data = imageData.data;

        // Apply color filter to simulate solar panel appearance
        for (let i = 0; i < data.length; i += 4) {
            // Reduce red and green components
            data[i] = Math.max(0, Math.min(255, data[i] * redFactor));           // Red
            data[i + 1] = Math.max(0, Math.min(255, data[i + 1] * greenFactor));   // Green
            
            // Adjust blue component: scale existing blue and add a boost
            data[i + 2] = Math.max(0, Math.min(255, data[i + 2] * blueChannelFactor + blueBoost)); // Blue
            
            // Alpha channel (data[i + 3]) remains unchanged
        }

        // Put the modified data back onto the canvas
        ctx.putImageData(imageData, 0, 0);
    } else {
        // If imageData could not be retrieved, we draw the original image again
        // This ensures the canvas is not blank if pixel processing failed.
        // The grid will be drawn over this original image.
        ctx.drawImage(originalImg, 0, 0, imgWidth, imgHeight);
        console.warn("Pixel processing skipped due to an issue retrieving imageData. Drawing grid over original image.");
    }

    // Draw grid lines if gridSize and gridLineWidth are positive
    if (gridSize > 0 && gridLineWidth > 0 && imgWidth > 0 && imgHeight > 0) {
        ctx.strokeStyle = gridColor;
        ctx.lineWidth = gridLineWidth;

        // Offset for sharper lines if lineWidth is odd (e.g., 1px)
        const offset = (gridLineWidth % 2 === 1) ? 0.5 : 0;

        // Vertical lines
        for (let x = gridSize; x < imgWidth; x += gridSize) {
            ctx.beginPath();
            ctx.moveTo(x + offset, 0);
            ctx.lineTo(x + offset, imgHeight);
            ctx.stroke();
        }

        // Horizontal lines
        for (let y = gridSize; y < imgHeight; y += gridSize) {
            ctx.beginPath();
            ctx.moveTo(0, y + offset);
            ctx.lineTo(imgWidth, y + offset);
            ctx.stroke();
        }
    }

    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 Solar Panel Filter Effect Tool allows users to apply a unique visual effect to images, simulating the appearance of solar panels. This tool modifies the color components of an image by reducing the red and green channels while enhancing the blue channel, creating a distinctive blue-toned effect reminiscent of solar panel aesthetics. Users can also overlay a customizable grid on the image, adjusting the grid’s size, color, and line width. This tool is ideal for graphic designers, marketers, and anyone looking to create visually engaging images with a solar panel theme for presentations, advertising materials, or digital artworks.

Leave a Reply

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