Please bookmark this page to avoid losing your image tool!

Image Aspect Ratio 2.55:1 Resizer

(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, mode = 'cover', bgColor = '#000000') {
    // Target aspect ratio for 2.55:1
    const targetAspectRatio = 2.55;
    
    // Original dimensions
    const sw = originalImg.width;
    const sh = originalImg.height;
    const srcRatio = sw / sh;

    let cw, ch;

    // Determine target canvas dimensions depending on the mode
    if (mode === 'contain') {
        // In "contain" mode, we want to pad the image, so we expand the shorter dimension
        if (srcRatio > targetAspectRatio) {
            // Source is wider, so we pad top and bottom
            cw = sw;
            ch = sw / targetAspectRatio;
        } else {
            // Source is narrower/taller, so we pad left and right
            ch = sh;
            cw = sh * targetAspectRatio;
        }
    } else {
        // For "cover" (crop) or "stretch", we fit the result within the maximum available bounds
        if (srcRatio > targetAspectRatio) {
            // Source is wider, we will crop the sides 
            ch = sh;
            cw = sh * targetAspectRatio;
        } else {
            // Source is taller, we will crop the top and bottom
            cw = sw;
            ch = sw / targetAspectRatio;
        }
    }

    const canvas = document.createElement('canvas');
    canvas.width = Math.round(cw);
    canvas.height = Math.round(ch);
    const ctx = canvas.getContext('2d');

    // Draw the image to the canvas based on the chosen mode
    if (mode === 'contain') {
        // Fill canvas with background color
        ctx.fillStyle = bgColor;
        ctx.fillRect(0, 0, canvas.width, canvas.height);
        
        // Calculate offsets to center the original image
        const dx = (canvas.width - sw) / 2;
        const dy = (canvas.height - sh) / 2;
        ctx.drawImage(originalImg, dx, dy, sw, sh);
        
    } else if (mode === 'stretch') {
        // Ignore aspect ratio of original image and stretch to fill canvas exactly
        ctx.drawImage(originalImg, 0, 0, canvas.width, canvas.height);
        
    } else {
        // Default mode: 'cover' (Crop from center)
        let sWidth = sw;
        let sHeight = sh;
        let sx = 0;
        let sy = 0;

        if (srcRatio > targetAspectRatio) {
            // Crop the sides evenly
            sWidth = sh * targetAspectRatio;
            sx = (sw - sWidth) / 2;
        } else {
            // Crop the top and bottom evenly
            sHeight = sw / targetAspectRatio;
            sy = (sh - sHeight) / 2;
        }

        ctx.drawImage(
            originalImg, 
            sx, sy, sWidth, sHeight, // Source clipping
            0, 0, canvas.width, canvas.height // Destination placement
        );
    }

    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 you to resize your images to a specific 2.55:1 aspect ratio. Users can choose from three different processing modes: ‘cover’ to crop the image from the center to fill the frame, ‘contain’ to add padding around the image to preserve the original dimensions, or ‘stretch’ to expand the image to fit the new ratio exactly. This is particularly useful for creators needing to format content for cinematic widescreen displays, specific digital signage, or specialized social media formats.

Leave a Reply

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