Please bookmark this page to avoid losing your image tool!

Image Size Resizer 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, targetWidth = 500, targetHeight = 0) {
    let w = Number(targetWidth);
    let h = Number(targetHeight);

    // Default to the original image width if an invalid width is provided
    if (isNaN(w) || w <= 0) {
        w = originalImg.width;
    }

    // If height is 0 or invalid, maintain the original aspect ratio
    if (isNaN(h) || h <= 0) {
        h = Math.round(originalImg.height * (w / originalImg.width));
    }

    const canvas = document.createElement('canvas');
    canvas.width = w;
    canvas.height = h;

    const ctx = canvas.getContext('2d');
    
    // Smooth image scaling
    ctx.imageSmoothingEnabled = true;
    ctx.imageSmoothingQuality = 'high';
    
    ctx.drawImage(originalImg, 0, 0, w, h);

    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 Size Resizer Tool allows users to adjust the dimensions of an image by specifying a target width and height. The tool includes an aspect ratio preservation feature, which automatically calculates the appropriate height when only a width is provided, ensuring the image does not appear stretched or distorted. This tool is useful for optimizing images for web use, social media uploads, or fitting specific layout requirements in digital documents.

Leave a Reply

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