Capability before assumption
Query input and output support at runtime instead of assuming codecs behave identically across devices.
Resize, transcode, target a byte budget, and control metadata with explicit Android and iOS capabilities.
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.
npm install react-native-image-compression-kitimport {
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
This builder produces React Native code. It does not compress an image in your browser.
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',
});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.