Image Resizer API

Category: media

Resize images to custom dimensions with aspect ratio lock. Supports PNG, JPG, and WebP output. Runs entirely in the browser using Canvas.

Endpoint

N/A Browser API (Canvas)
No Server API

Response

Content-Type: N/A

This tool resizes images in the browser using the Canvas API. No server-side API is available.

// Browser-only: uses Canvas API

cURL Example

# No cURL equivalent — this tool runs in the browser

Code Samples

// Image resizing using Canvas
const canvas = document.createElement('canvas');
canvas.width = targetWidth;
canvas.height = targetHeight;
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0, targetWidth, targetHeight);

canvas.toBlob(blob => {
    const url = URL.createObjectURL(blob);
    // Download resized image
}, 'image/png');
# For server-side image resizing:
from PIL import Image

img = Image.open('photo.jpg')
img.thumbnail((800, 600))
img.save('resized.jpg')
// For server-side image resizing:
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.awt.Graphics2D;

BufferedImage original = ImageIO.read(new File("photo.jpg"));
BufferedImage resized = new BufferedImage(800, 600, BufferedImage.TYPE_INT_RGB);
Graphics2D g = resized.createGraphics();
g.drawImage(original, 0, 0, 800, 600, null);
ImageIO.write(resized, "jpg", new File("resized.jpg"));