Please bookmark this page to avoid losing your image tool!

Image Converter

(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, format = "jpeg", quality = 0.92) {
    const canvas = document.createElement('canvas');
    const width = originalImg.naturalWidth || originalImg.width;
    const height = originalImg.naturalHeight || originalImg.height;
    
    canvas.width = width;
    canvas.height = height;
    
    const ctx = canvas.getContext('2d');
    
    // Normalize the requested format to a standard MIME type
    let mimeType = String(format).toLowerCase().trim();
    if (mimeType === 'jpg') {
        mimeType = 'jpeg';
    }
    if (!mimeType.startsWith('image/')) {
        mimeType = 'image/' + mimeType;
    }

    // Fill with a white background for formats that don't support transparency
    // to prevent transparent areas from turning black.
    if (mimeType === 'image/jpeg') {
        ctx.fillStyle = '#FFFFFF';
        ctx.fillRect(0, 0, width, height);
    }
    
    // Draw the original image onto the canvas
    ctx.drawImage(originalImg, 0, 0, width, height);
    
    // Convert canvas to the specified format
    const parsedQuality = parseFloat(quality);
    const validQuality = (isNaN(parsedQuality) || parsedQuality < 0 || parsedQuality > 1) ? 0.92 : parsedQuality;
    const dataUrl = canvas.toDataURL(mimeType, validQuality);
    
    // Create and return the new image object
    const resultImg = new Image();
    resultImg.src = dataUrl;
    resultImg.width = width;
    resultImg.height = height;
    
    return resultImg;
}

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 Converter tool allows users to change the file format and adjust the quality of their images. It can convert images to various formats, such as JPEG, while providing the option to fine-tune the compression quality. This tool is useful for optimizing images for web use, reducing file sizes for easier sharing, or converting files to specific formats required by different software applications.

Leave a Reply

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