Appearance
@mdehub/core
compressImage(input, options?)
Compress an image with Squoosh-derived WASM codecs.
| Option | Type | Default |
|---|---|---|
mimeType | 'image/webp' | 'image/jpeg' | 'image/png' | 'image/webp' |
quality | number (1–100) | 80 |
gif | boolean | { colors? } | false |
maxWidth | number | — |
maxHeight | number | — |
signal | AbortSignal | — |
onProgress | (n: number) => void | — |
preferWorker | boolean | true |
Returns { blob, width, height, bytesBefore, bytesAfter }.
Input is Blob | ArrayBuffer. Images are never upscaled. GIF inputs remain image/gif; they are unchanged by default. Set gif: { colors: 128 } to opt into lossy palette optimization while preserving animation, dimensions, delays, and looping. The original is returned when it is smaller. mimeType, quality, and resize options do not apply to GIFs.
Also exported: detectMime, computeTargetSize, CompressError, CompressAbortError.