Skip to content
Compressly logo
Open-source developer tool

Compressly — zero-dependency client-side image compression.

An ultra-fast image compression SDK for Next.js, React, and modern web apps. Runs off-thread in Web Workers with OffscreenCanvas, fixes iPhone portrait EXIF flipping, guarantees target file sizes via adaptive loops, and cuts cloud transcoding costs to $0.

Compressly client-side image compression SDK architecture preview

Zero Dependencies

< 3 KB Bundle

Web Worker Off-Thread

Auto EXIF Orientation

Adaptive Target Size

Batch Processing Pool

Lossless WebP / JPEG

Next.js & React Ready

The Problem

Modern smartphone cameras take high-resolution photos ranging from 15MB to 25MB. Uploading these raw files creates severe network lag, triggers 413 Payload Too Large errors, runs up massive cloud transcoding bills (Cloudinary / AWS), or forces developers to show frustrating 'file size too large' validation toasts.

The Solution

Compressly eliminates the cloud pipeline by compressing and downscaling images directly inside the user's browser in < 120ms before upload. By utilizing Web Workers and OffscreenCanvas, it keeps UI interactions running at a buttery-smooth 60 FPS without ever blocking the main thread.

Quick Start Example
import { compressImage } from "compressly";

// 1. Intercept user's file input client-side:
const handleFileChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
  const rawFile = event.target.files?.[0];
  if (!rawFile) return;

  // 2. Compress from 20MB -> ~250KB in < 120ms (Web Worker):
  const optimizedFile = await compressImage(rawFile, {
    maxWidth: 1920,
    quality: 0.82,
    targetSizeMB: 0.5, // Smart adaptive size loop
    useWorker: true,    // 60 FPS background thread
  });

  // 3. Upload 98% smaller payload to S3 / Backend:
  const formData = new FormData();
  formData.append("photo", optimizedFile);
  await fetch("/api/upload", { method: "POST", body: formData });
};
Architecture Note

Compressly executes 100% on the client device. It requires zero server resources, incurs $0 in cloud transcoding fees, reduces network upload bandwidth by over 98%, and automatically fixes vertical iPhone photos flipping sideways via native EXIF orientation handling.

Features
compressImage API
compressImages concurrent batch pool
useImageCompressor React hook
Web Worker off-thread processing via OffscreenCanvas
Adaptive target size loop (targetSizeMB: 0.5)
Auto EXIF orientation (createImageBitmap)
Zero runtime dependencies (< 3 KB)
Lossless & lossy WebP / JPEG output
TypeScript declarations (.d.ts)
ESM and CJS support
SSR-Safe (Next.js 14/15 ready)
Progress callbacks (onProgress)
Developer Value
$0 cloud image transcoding fees
Over 98% bandwidth reduction on every upload
Super fast uploads on slow cellular connections
Zero main-thread UI freeze (60 FPS responsiveness)
Eliminates user-facing 'File too large' error friction
Seamless drop-in replacement for input file handlers