Please bookmark this page to avoid losing your image tool!

Image Resize 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 = 500, maintainAspectRatio = 1) {
    let width = targetWidth;
    let height = targetHeight;
    
    // Calculate new dimensions
    if (maintainAspectRatio === 1) {
        const ratio = originalImg.width / originalImg.height;
        if (targetWidth / targetHeight > ratio) {
            width = targetHeight * ratio;
            height = targetHeight;
        } else {
            width = targetWidth;
            height = targetWidth / ratio;
        }
    }
    
    // Create the canvas and set its dimensions to the resized width/height
    const canvas = document.createElement('canvas');
    canvas.width = Math.max(1, Math.round(width));
    canvas.height = Math.max(1, Math.round(height));
    
    const ctx = canvas.getContext('2d');
    
    // Apply high quality image smoothing for better resizing results
    ctx.imageSmoothingEnabled = true;
    ctx.imageSmoothingQuality = 'high';
    
    // Draw the resized image onto the canvas
    ctx.drawImage(originalImg, 0, 0, canvas.width, canvas.height);
    
    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 Resize Tool allows users to adjust the dimensions of an image to specific width and height requirements. It features an option to maintain the original aspect ratio, ensuring that images do not appear stretched or distorted during the resizing process. This tool is useful for optimizing images for web use, preparing photos for social media uploads, or adjusting image sizes to meet specific platform constraints.

Leave a Reply

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