Home / SEO and Site Tools / Responsive Image Maker

Responsive Image Maker in JavaScript, Free with Live Demo

Free responsive image maker in plain JavaScript. Drop in one photo, get it resized to several widths as WebP or JPEG, compare file sizes and copy ready srcset and picture code.

Open live demoDownload HTML fileView code on GitHub
Responsive Image Maker JavaScript project: a tool that resizes one photo into several sizes and writes the srcset code

Runs on: Canvas toBlob and createImageBitmap. Works in all modern browsers. AVIF export depends on the browser; the tool falls back to WebP.

What is the Responsive Image Maker?

An image resizer for the web. Start with the sample photo or drop in your own, choose widths, a format and quality, and get resized files in a few seconds.

A table shows each file size and how much smaller it is than the original. The tool also writes the srcset or picture code so each device loads the right size.

Good for

  • Preparing photos for a website
  • Shops with product images
  • Blogs and portfolios
  • Speeding up slow pages

What this project does

How it works

  1. Decode oncecreateImageBitmap decodes the photo a single time. Every size is then drawn from that bitmap onto a canvas of the right width.
  2. Encode to modern formatscanvas.toBlob saves each size as WebP, JPEG or AVIF at the quality you choose, and the file sizes are shown so you can compare.
  3. Let the browser chooseThe srcset and sizes code lists every file with its width. Each device then downloads only the size it needs.

The key JavaScript

This is the heart of the project. The full file has the rest, including the screen layout and error handling.

const bitmap = await createImageBitmap(file);
for (const w of [400, 800, 1200]) {
  const c = document.createElement("canvas");
  c.width = w; c.height = Math.round(bitmap.height * w / bitmap.width);
  c.getContext("2d").drawImage(bitmap, 0, 0, c.width, c.height);
  const blob = await new Promise((r) => c.toBlob(r, "image/webp", 0.75));
}
// <img srcset="photo-400.webp 400w, photo-800.webp 800w, photo-1200.webp 1200w"
//      sizes="(max-width: 700px) 100vw, 700px">

How to use it

  1. Click Download HTML file above.
  2. Open the file in a code editor, like VS Code.
  3. Run it from a local server with npx serve . so the camera, microphone and AI features are allowed.
  4. Change the text and colors, then upload it to GitHub Pages, Netlify or your own site. It is one file with no build step.

Questions people ask

Are my photos uploaded?

No. Everything happens in your browser. The photo never leaves your device.

Which format should I use?

WebP works everywhere today and is usually 25 to 35 percent smaller than JPEG. AVIF is smaller still where supported.

What does the sizes attribute do?

It tells the browser how wide the image will be shown, so it can pick the best file before the page layout is ready.

More SEO and Site Tools projects