Skip to content

React Native Image Compression KitPredictable native image compression

Resize, transcode, target a byte budget, and control metadata with explicit Android and iOS capabilities.

Image Compression Kit logo
Android 23+File and content URIs with device-gated codecs.
iOS 13.4+ImageIO-backed input and runtime-gated WebP output.
Expo dev buildCustom native code requires prebuild; Expo Go is unsupported.

Current release: 0.4.0 is published on npm latest. The immutable tag, GitHub Release, registry provenance, and retained evidence all bind the same verified artifact and source.

Install

bash
npm install react-native-image-compression-kit
ts
import {
  compressImage,
  getImageCompressionCapabilities,
} from 'react-native-image-compression-kit';

const capabilities = await getImageCompressionCapabilities();
const canWriteWebP = capabilities.formats.some(
  item => item.format === 'webp' && item.output
);

const result = await compressImage({
  source: { uri: imageUri },
  resize: { maxWidth: 2048, maxHeight: 2048, mode: 'contain' },
  output: { format: canWriteWebP ? 'webp' : 'jpeg', quality: 80 },
  metadata: 'safe',
});

The source must be a local URI available to native code. Remote URLs and data URIs are intentionally outside the package scope.

Configuration builder

Generate capability-aware code

This builder produces React Native code. It does not compress an image in your browser.

React Native
const requestedFormat = 'webp' as const;
const capabilities = await getImageCompressionCapabilities();
const canWrite = capabilities.formats.some(
  item => item.format === requestedFormat && item.output
);
const outputFormat = canWrite ? requestedFormat : 'jpeg';

const result = await compressImage({
  source: { uri: imageUri },
  resize: { maxWidth: 2048, mode: 'contain' },
  output: { format: outputFormat, quality: 80, maxBytes: 500000 },
  metadata: 'safe',
});

What this site demonstrates

The native result explorer presents artifacts produced by the Android and iOS example apps, including options, byte counts, dimensions, platform information, and digests. It does not substitute a browser codec for the package's native pipeline.

Start with the installation guide, then choose a recipe and review the capability matrix.

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