How I Built a Free Image Landscape Converter That Runs Entirely in Your Browser

# javascript# showdev# sideprojects# webdev
How I Built a Free Image Landscape Converter That Runs Entirely in Your Browsercai13808519901-cpu

Have you ever needed to quickly convert a portrait photo to landscape format — maybe for a YouTube...

Have you ever needed to quickly convert a portrait photo to landscape format — maybe for a YouTube thumbnail, a LinkedIn banner, or a presentation slide — but didn't want to upload your personal photos to some random website?

That's exactly the problem I solved with Image Landscape Converter.

The Core Challenge

Most online image tools work by uploading your file to a server, processing it there, and sending it back. This creates three problems:

  1. Privacy — your images leave your device
  2. Speed — upload/download time adds latency
  3. Cost — server processing costs money

My approach: do everything in the browser using the Canvas API.

How It Works

The entire conversion pipeline runs client-side:

function convertToLandscape(imageFile, targetRatio = '16:9') {
  return new Promise((resolve) => {
    const img = new Image();
    img.onload = () => {
      const canvas = document.createElement('canvas');
      const [w, h] = targetRatio.split(':').map(Number);
      const outputWidth = Math.max(img.width, img.height * (w / h));
      const outputHeight = outputWidth * (h / w);
      canvas.width = outputWidth;
      canvas.height = outputHeight;
      const ctx = canvas.getContext('2d');
      ctx.fillStyle = '#000000';
      ctx.fillRect(0, 0, outputWidth, outputHeight);
      const x = (outputWidth - img.width) / 2;
      const y = (outputHeight - img.height) / 2;
      ctx.drawImage(img, x, y);
      resolve(canvas.toDataURL('image/jpeg', 0.92));
    };
    img.src = URL.createObjectURL(imageFile);
  });
}
Enter fullscreen mode Exit fullscreen mode

The Blur Fill Algorithm

The most popular feature is the "blur fill" background — instead of black bars, the image edges are extended with a blurred version of itself:

function applyBlurFill(ctx, img, outputWidth, outputHeight) {
  const scale = Math.max(outputWidth / img.width, outputHeight / img.height);
  const bgW = img.width * scale;
  const bgH = img.height * scale;
  ctx.filter = 'blur(20px)';
  ctx.drawImage(img, (outputWidth - bgW) / 2, (outputHeight - bgH) / 2, bgW, bgH);
  ctx.filter = 'none';
  ctx.drawImage(img, (outputWidth - img.width) / 2, (outputHeight - img.height) / 2);
}
Enter fullscreen mode Exit fullscreen mode

Key Lessons from Building This

1. The Canvas API is incredibly powerful — but also quirky:

  • ctx.filter isn't supported in all browsers (Firefox had issues)
  • Large canvases (>16384px) fail silently in some browsers
  • Mobile browsers have stricter memory limits

2. Privacy is a real selling point — many users specifically mention "no uploads" in reviews. People care about where their photos go.

3. Browser-native tools can be competitive — no backend, no database, no server costs. The whole thing is stateless.

Try It

👉 imagelandscapeconverter.online — free, no signup, works offline after first load.

Built with Next.js + TypeScript + Canvas API.

What other browser-native tools do you think are worth building? Drop ideas in the comments!