Please bookmark this page to avoid losing your image tool!

Image Text Overlay 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,
    text = 'BE STRONG,\nWORK HARD\nBROTHER',
    font = 'Impact',
    fontSize = null,
    color = '#FFFFFF',
    outlineColor = '#000000',
    outlineWidth = null,
    x = null,
    y = null,
    textAlign = 'center',
    lineSpacing = 1.2
) {
    // Create a canvas element
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');

    // Set canvas dimensions to match the image
    const w = originalImg.naturalWidth || originalImg.width;
    const h = originalImg.naturalHeight || originalImg.height;
    canvas.width = w;
    canvas.height = h;

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

    // --- Calculate dynamic default values ---
    // If a value is null, calculate a default based on image size.
    const finalFontSize = fontSize === null ? Math.max(12, Math.round(w / 12)) : fontSize;
    const finalOutlineWidth = outlineWidth === null ? Math.max(1, Math.round(finalFontSize / 25)) : outlineWidth;
    const finalX = x === null ? w / 2 : x;
    const finalY = y === null ? h / 2 : y;

    // --- Font Loading ---
    const webSafeFonts = [
        "arial", "verdana", "helvetica", "tahoma", "trebuchet ms", 
        "times new roman", "georgia", "garamond", "courier new", 
        "brush script mt", "impact"
    ];
    const isWebSafe = webSafeFonts.some(safeFont => font.toLowerCase().includes(safeFont));

    if (!isWebSafe) {
        try {
            // Attempt to load the font using the Font Loading API.
            // This is a best-effort approach that relies on the browser's ability to find the font
            // (e.g., if it's a known Google Font or a system font).
            await document.fonts.load(`${finalFontSize}px ${font}`);
        } catch (e) {
            console.warn(`Font '${font}' could not be loaded. Falling back to 'Arial'.`, e);
            font = 'Arial'; // Fallback to a web-safe font on failure
        }
    }
    
    // --- Text Styling and Positioning ---
    ctx.font = `${finalFontSize}px ${font}`;
    ctx.fillStyle = color;
    ctx.strokeStyle = outlineColor;
    ctx.lineWidth = finalOutlineWidth;
    ctx.textAlign = textAlign;
    ctx.textBaseline = 'middle'; // Align text vertically to its center

    // --- Drawing Text ---
    const lines = text.split('\n');
    const lineHeight = finalFontSize * lineSpacing;
    const totalTextHeight = (lines.length - 1) * lineHeight;

    // Calculate the Y position for the first line to center the entire text block
    const firstLineY = finalY - totalTextHeight / 2;

    lines.forEach((line, index) => {
        const currentY = firstLineY + (index * lineHeight);

        // Draw outline if width is greater than 0
        if (finalOutlineWidth > 0) {
            ctx.strokeText(line, finalX, currentY);
        }

        // Draw the filled text
        ctx.fillText(line, finalX, currentY);
    });

    // Return the canvas element
    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 Text Overlay Creator is a versatile online tool that allows users to add customizable text overlays onto their images. With options to adjust font style, size, color, outline, and positioning, this tool is ideal for creating motivational posters, personalized graphics, social media content, and more. This tool enables users to enhance their images by conveying messages or artistic expressions directly on the image, making it perfect for both personal and professional use.

Leave a Reply

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

Other Image Tools:

Comprehensive Image Utility Tool

Image To 2000s Low Quality Digital Camera Effect Tool

Image Headshot Cropper with 1:1 Resolution

Image AI Filter Effect Remover

Image Gloomy Effect Editor

Image Japanese Anime-Style Generator

3D Cartoon Style Image Creator

Image To Pixel-Style Converter

Image Black And White HUD Style With VHS Effects

Black and White MQ1 Reaper Drone Targeting Pod Image

Image Filter for MQ1 Reaper Drone Targeting Pod

Image Hyper-Realistic Portrait Triptych Generator

Image To Professional Architectural Render Blueprint Converter

Image Ultraviolet Camera Filter

Image Portrait Generator with Warm Golden Hour Lighting

Image Softly Lit Portrait Generator

Image Petal Count Identifier

Image Ball Creator

Image To CAD-Style Blueprint Converter

Image To Blueprint CAD Style Converter

Image To Clean CAD Blueprint Generator

Image To CAD Blueprint Generator

Image To Technical Blueprint Style Converter

Image To Blueprint-Style Drawing Converter

Image To Technical Blueprint Converter

Architectural Plan to Technical Blueprint Image Converter

Architectural Plan To Blueprint-Style Image Converter

Image To Blueprint Architectural Style Converter

Image Background Replacement To White

Image To Dot Outline Converter

Image To Vertical Halftone Converter

Image Transparent Hologram Effect Generator

Image Blue Twilight Filter Applicator

Image Golden Ratio Spiral Generator for A4

Photo Black and White Floyd-Steinberg Dithering for Acrylic Engraving

Image Cover Texture Generator

See All →