omni-compress - v2.3.1
    Preparing search index...

    Function compressImage

    • Compresses an image to the specified format.

      Automatically selects the fastest available engine:

      • Fast path: OffscreenCanvas (JPEG/PNG/WebP — zero Wasm, hardware-accelerated)
      • Heavy path: FFmpeg Wasm (AVIF and all other formats, or fallback)
      • Node: native ffmpeg binary via child_process

      Parameters

      Returns Promise<CompressResult>

      const { blob, ratio } = await compressImage(file, { format: 'webp', quality: 0.8 });
      console.log(`Compressed to ${(ratio * 100).toFixed(0)}% of original size`);