Skip to content

Capabilities and fallbacks

Call getImageCompressionCapabilities() at runtime. Availability can differ by Android API/device codecs and iOS ImageIO destinations.

CapabilityAndroidiOS
JPEG/PNG inputYesYes
WebP inputYesStatic ImageIO decode
GIF inputStatic first frameStatic first frame
HEIC/HEIF inputSDK/device gatedStatic ImageIO decode
AVIF inputAndroid 14+ platform decoderRuntime ImageIO source gated
JPEG/PNG outputYesYes
WebP outputYesRuntime ImageIO destination gated
HEIC/HEIF/AVIF outputNot implementedNot implemented
Target sizeJPEG, WebPJPEG, runtime-available WebP
Animation preservationNot implementedNot implemented
Decode-time downsamplingYesYes
Maximum concurrent operations22
CancellationYesYes

Both platforms currently report:

ts
{
  maxConcurrentOperations: 2,
  supportsDecodeDownsampling: true,
  supportsCancellation: true,
  resourceLimits: {
    maxSourceDimension: 32_768,
    maxSourcePixels: 100_000_000,
    maxWorkingPixels: 25_000_000,
  },
}

These limits are applied before full decode. Large sources can still be processed when resize bounds permit decode-time downsampling below the working pixel limit.

Fallback pattern

ts
const capabilities = await getImageCompressionCapabilities();

function canOutput(format: 'jpeg' | 'png' | 'webp') {
  return capabilities.formats.some(
    item => item.format === format && item.output
  );
}

const format = canOutput('webp') ? 'webp' : 'jpeg';

Do not infer output support from the input extension. Do not assume another device with the same platform has an identical codec set.

Metadata fallback

preserve is intentionally narrow: JPEG source to JPEG output. Prefer safe for a privacy-filtered/default result and strip when the application does not need metadata. See metadata details.

Native output claims are capability-driven and evidence-backed.