Eskillsfy

Home / Blog / Images

Images · 23 Nov 2026

Image Resizer: how it works and how to build one

Resize images to an exact width or a preset. This guide explains what happens behind the button and shows the code, so you can build your own.

What it does

Set a width and the height follows the aspect ratio, or pick a preset for thumbnails, product cards, social posts and hero images.

When to use it

  • Profile pictures
  • Product photos
  • Upload size limits

How to use it

  1. Drop images or click to choose them.
  2. Type a width or pick a preset.
  3. Download the resized images.

Try it free in your browser, nothing is uploaded: https://eskillsfy.com/tools/image-resizer

How it works

Resizing draws the image onto a canvas of the new size. Canvas scaling with imageSmoothingQuality = ‘high’ gives good results for small reductions; for big reductions, halving the size in steps keeps it sharp.

Keeping the aspect ratio means computing one side from the other: newHeight = newWidth × height ÷ width.

Build it yourself

Here is the core of the tool. It has no dependencies unless noted, so you can paste it into any TypeScript or JavaScript project.

resize.ts (ts)

export async function resize(file: File, width: number, type = "image/jpeg") {
  const img = await createImageBitmap(file);
  const height = Math.round((width * img.height) / img.width);
  const c = Object.assign(document.createElement("canvas"), { width, height });
  const g = c.getContext("2d")!;
  g.imageSmoothingQuality = "high";
  g.drawImage(img, 0, 0, width, height);
  return new Promise<Blob>((r) => c.toBlob((b) => r(b!), type, 0.9));
}

Make it production-ready

  • Step down by halves for large reductions.
  • Offer fit modes: cover, contain and stretch.

Questions

Will it make small images bigger?

It can, but upscaling makes them blurry. Start from the largest original you have.

Try the Image Resizer

Free, runs in your browser, nothing is uploaded.

Open it
Keep reading

More in Images

All posts