Please bookmark this page to avoid losing your image tool!

Website Favicon And Logo PNG Generator 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, size = 512, backgroundColor = "transparent", padding = 5, cornerRadius = 0) {
    // Clean and clamp parameters
    const targetSize = Math.max(16, Number(size) || 512); // Standard sizes like 16, 32, 64, 192, 512
    const paddingPercent = Math.max(0, Math.min(45, Number(padding) || 0)); // Limit padding up to 45%
    const radiusPercent = Math.max(0, Math.min(50, Number(cornerRadius) || 0)); // 0 = square, 50 = circle

    const canvas = document.createElement('canvas');
    canvas.width = targetSize;
    canvas.height = targetSize;
    const ctx = canvas.getContext('2d');

    // Apply corner radius (clipping mask for the logo/favicon base)
    if (radiusPercent > 0) {
        // Calculate corner radius in pixels
        const radiusPx = (targetSize / 2) * (radiusPercent / 50);
        
        ctx.beginPath();
        ctx.moveTo(radiusPx, 0);
        ctx.lineTo(targetSize - radiusPx, 0);
        ctx.quadraticCurveTo(targetSize, 0, targetSize, radiusPx);
        ctx.lineTo(targetSize, targetSize - radiusPx);
        ctx.quadraticCurveTo(targetSize, targetSize, targetSize - radiusPx, targetSize);
        ctx.lineTo(radiusPx, targetSize);
        ctx.quadraticCurveTo(0, targetSize, 0, targetSize - radiusPx);
        ctx.lineTo(0, radiusPx);
        ctx.quadraticCurveTo(0, 0, radiusPx, 0);
        ctx.closePath();
        ctx.clip();
    }

    // Apply background color if it's not set to transparent
    const bg = backgroundColor.trim().toLowerCase();
    if (bg !== 'transparent' && bg !== 'rgba(0,0,0,0)' && bg !== 'rgba(0, 0, 0, 0)') {
        ctx.fillStyle = backgroundColor;
        ctx.fillRect(0, 0, targetSize, targetSize);
    }

    // Calculate maximum available area for the image, applying the padding safe-zone
    const paddingPx = (paddingPercent / 100) * targetSize;
    const drawableSize = targetSize - (paddingPx * 2);

    // Calculate the scale to fit the image perfectly within the bounding box
    const scale = Math.min(
        drawableSize / originalImg.width, 
        drawableSize / originalImg.height
    );
    
    const drawWidth = originalImg.width * scale;
    const drawHeight = originalImg.height * scale;

    // Horizontally and vertically center the image in the canvas
    const x = (targetSize - drawWidth) / 2;
    const y = (targetSize - drawHeight) / 2;

    // Render the original image onto the canvas
    ctx.drawImage(originalImg, x, y, drawWidth, drawHeight);

    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

This tool allows users to transform images into optimized PNG files specifically formatted for website favicons and logos. It provides customization options to adjust the output dimensions, add background colors, apply padding for safe zones, and adjust corner radii to create rounded or circular icons. This tool is ideal for web developers and designers who need to quickly generate standardized assets for browser tabs, mobile app icons, or brand branding elements.

Leave a Reply

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