Please bookmark this page to avoid losing your image tool!

Dwarf Person Image Generator

(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, headRatio = 0.25, torsoRatio = 0.35, torsoSquash = 0.8, legSquash = 0.4) {
    // Parse parameters to guarantee they are numbers
    headRatio = parseFloat(headRatio);
    torsoRatio = parseFloat(torsoRatio);
    torsoSquash = parseFloat(torsoSquash);
    legSquash = parseFloat(legSquash);

    // Validate values and use fallbacks if necessary
    if (isNaN(headRatio) || headRatio < 0) headRatio = 0.25;
    if (isNaN(torsoRatio) || torsoRatio < 0) torsoRatio = 0.35;
    if (headRatio + torsoRatio > 1) {
        headRatio = 0.25;
        torsoRatio = 0.35;
    }
    if (isNaN(torsoSquash) || torsoSquash <= 0) torsoSquash = 0.8;
    if (isNaN(legSquash) || legSquash <= 0) legSquash = 0.4;

    const w = originalImg.width;
    const h = originalImg.height;

    // Calculate source heights for each segment using integer values
    // to prevent any tiny pixel-gap artifacts when rendering
    const srcHeadH = Math.round(h * headRatio);
    const srcTorsoH = Math.round(h * torsoRatio);
    const srcLegH = h - srcHeadH - srcTorsoH;

    // Calculate destination squashed heights for the segments
    // Head remains unscaled vertically, torso is slightly compressed horizontally, and legs heavily compressed
    const dstHeadH = srcHeadH;
    const dstTorsoH = Math.round(srcTorsoH * torsoSquash);
    const dstLegH = Math.round(srcLegH * legSquash);

    // Initialize Canvas
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');

    // Keep horizontal width the same to provide a stout aesthetic organically 
    canvas.width = w;
    canvas.height = dstHeadH + dstTorsoH + dstLegH;

    // Set smoothing to high for squashed segments
    ctx.imageSmoothingEnabled = true;
    ctx.imageSmoothingQuality = 'high';

    // 1. Draw Head Section (Normal scale)
    if (srcHeadH > 0) {
        ctx.drawImage(originalImg, 
            0, 0, w, srcHeadH, 
            0, 0, w, dstHeadH);
    }
    
    // 2. Draw Torso Section (Moderate Squash)
    if (srcTorsoH > 0) {
        ctx.drawImage(originalImg, 
            0, srcHeadH, w, srcTorsoH, 
            0, dstHeadH, w, dstTorsoH);
    }
    
    // 3. Draw Legs Section (Heavy Squash)
    if (srcLegH > 0) {
        ctx.drawImage(originalImg, 
            0, srcHeadH + srcTorsoH, w, srcLegH, 
            0, dstHeadH + dstTorsoH, w, dstLegH);
    }

    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 Dwarf Person Image Generator is a specialized image manipulation tool that alters the proportions of a person in a photo to create a stout, compressed aesthetic. By segmenting an image into head, torso, and leg sections, the tool applies different vertical scaling factors to each part, allowing for the creation of stylized, short-stature character versions of original images. This tool can be used for creative character design, generating humorous avatars, or creating stylized assets for digital art and social media.

Leave a Reply

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