Please bookmark this page to avoid losing your image tool!

Image Identifier Textbox 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.
function processImage(originalImg, text = "Identifier", position = "bottom-left", bgColor = "rgba(0, 0, 0, 0.7)", textColor = "#ffffff", fontSize = 24) {
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');
    
    // Ensure fontSize is a number
    const parsedFontSize = Number(fontSize) || 24;
    
    const width = originalImg.width;
    const height = originalImg.height;
    canvas.width = width;
    canvas.height = height;
    
    // Draw the original image
    ctx.drawImage(originalImg, 0, 0, width, height);
    
    if (!text || String(text).trim() === '') {
        return canvas;
    }
    
    const padding = parsedFontSize * 0.5;
    ctx.font = `${parsedFontSize}px Arial, sans-serif`;
    ctx.textBaseline = 'top';
    
    // Measure text dimensions
    const textStr = String(text);
    const textMetrics = ctx.measureText(textStr);
    const textWidth = textMetrics.width;
    
    const boxWidth = textWidth + padding * 2;
    const boxHeight = parsedFontSize + padding * 2;
    
    let x = 0;
    let y = 0;
    const margin = parsedFontSize * 0.5;
    
    // Determine textbox coordinates based on position parameter
    switch (String(position).toLowerCase()) {
        case "top-left":
            x = margin;
            y = margin;
            break;
        case "top-right":
            x = width - boxWidth - margin;
            y = margin;
            break;
        case "bottom-right":
            x = width - boxWidth - margin;
            y = height - boxHeight - margin;
            break;
        case "bottom-left":
        default:
            x = margin;
            y = height - boxHeight - margin;
            break;
    }
    
    // Draw background box with rounded corners
    ctx.fillStyle = String(bgColor);
    const radius = 5;
    
    ctx.beginPath();
    ctx.moveTo(x + radius, y);
    ctx.lineTo(x + boxWidth - radius, y);
    ctx.quadraticCurveTo(x + boxWidth, y, x + boxWidth, y + radius);
    ctx.lineTo(x + boxWidth, y + boxHeight - radius);
    ctx.quadraticCurveTo(x + boxWidth, y + boxHeight, x + boxWidth - radius, y + boxHeight);
    ctx.lineTo(x + radius, y + boxHeight);
    ctx.quadraticCurveTo(x, y + boxHeight, x, y + boxHeight - radius);
    ctx.lineTo(x, y + radius);
    ctx.quadraticCurveTo(x, y, x + radius, y);
    ctx.closePath();
    ctx.fill();
    
    // Draw the text
    ctx.fillStyle = String(textColor);
    // Adjusted y padding slightly down to account for typical uppercase letter height making visual centering better
    ctx.fillText(textStr, x + padding, y + padding + (parsedFontSize * 0.1));
    
    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 Identifier Textbox Creator allows you to add custom text overlays with background boxes to your images. You can customize the text content, font size, text color, and background color, as well as choose from various corner positions like top-left, top-right, bottom-left, or bottom-right. This tool is useful for watermarking photos, labeling diagrams, adding captions to social media posts, or identifying objects within an image.

Leave a Reply

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