Please bookmark this page to avoid losing your image tool!

Image Crossbar Adder

(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, style = 'cross', thickness = 10, color = '#FF0000', opacity = 0.8, posX = 50, posY = 50) {
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');
    const width = originalImg.width;
    const height = originalImg.height;

    canvas.width = width;
    canvas.height = height;

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

    // Parse and sanitize parameters
    const lineThickness = Math.max(1, Number(thickness) || 10);
    const alpha = Math.max(0, Math.min(1, Number(opacity)));
    const positionX = Number(posX) >= 0 && Number(posX) <= 100 ? Number(posX) : 50;
    const positionY = Number(posY) >= 0 && Number(posY) <= 100 ? Number(posY) : 50;
    
    // Calculate actual pixel coordinates from percentages
    const xPos = (positionX / 100) * width;
    const yPos = (positionY / 100) * height;

    // Configure crossbar drawing properties
    ctx.lineWidth = lineThickness;
    ctx.strokeStyle = color || '#FF0000';
    ctx.globalAlpha = isNaN(alpha) ? 0.8 : alpha;
    ctx.lineCap = 'butt'; // Gives sharp edges to the end of the lines

    ctx.beginPath();
    const drawStyle = String(style).toLowerCase().trim();
    
    if (drawStyle === 'x') {
        // Draw an 'X' from corner to corner
        ctx.moveTo(0, 0);
        ctx.lineTo(width, height);
        ctx.moveTo(width, 0);
        ctx.lineTo(0, height);
    } else if (drawStyle === 'horizontal') {
        // Draw a single horizontal bar
        ctx.moveTo(0, yPos);
        ctx.lineTo(width, yPos);
    } else if (drawStyle === 'vertical') {
        // Draw a single vertical bar
        ctx.moveTo(xPos, 0);
        ctx.lineTo(xPos, height);
    } else {
        // Default to 'cross' - intersecting horizontal and vertical bars
        ctx.moveTo(0, yPos);
        ctx.lineTo(width, yPos);
        ctx.moveTo(xPos, 0);
        ctx.lineTo(xPos, height);
    }
    
    // Apply the drawing
    ctx.stroke();

    // Reset global alpha back to default
    ctx.globalAlpha = 1.0;

    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 Crossbar Adder is a tool designed to overlay geometric line patterns onto images. Users can add various styles of bars, including horizontal lines, vertical lines, an ‘X’ shape, or a crosshair pattern. The tool provides customization options for line thickness, color, opacity, and the specific placement of the lines. This utility is useful for creating watermarks, marking specific areas of interest in photos, or adding structural design elements to visual content.

Leave a Reply

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