Skip to content

Errors and troubleshooting

ts
import {
  compressImage,
  ImageCompressionKitError,
  type ImageCompressionKitErrorCode,
} from 'react-native-image-compression-kit';

try {
  await compressImage(options);
} catch (error) {
  if (error instanceof ImageCompressionKitError) {
    const code: ImageCompressionKitErrorCode = error.code;
    console.warn(code, error.message);
  }
}
CodeTypical causeRecovery
ERR_INVALID_OPTIONSInvalid quality, size, format, resize, or metadata valueValidate application input before retrying.
ERR_UNSUPPORTED_SOURCERemote/data URI or unreadable URI kindMaterialize a local readable file or picker URI.
ERR_UNSUPPORTED_FORMATRuntime cannot decode or encode the selected formatQuery capabilities and choose a fallback.
ERR_NATIVE_MODULE_UNAVAILABLENative app was not rebuilt after installReinstall pods if needed and rebuild the binary.
ERR_NOT_IMPLEMENTEDRequested output or behavior is intentionally unavailableUse a documented supported output.
ERR_FILE_ACCESSPermission, security scope, or cache write failureKeep URI access alive and verify available storage.
ERR_DECODE_FAILEDCorrupt, incomplete, or unsupported input bytesValidate or re-materialize the source image.
ERR_ENCODE_FAILEDRuntime encoder failedCheck capabilities, target size, and output format.
ERR_RESOURCE_LIMITSource dimensions/pixels or required decoded work exceed the native limitAdd smaller resize bounds or reject the source before retrying.
ERR_CANCELLEDThe optional abort control cancelled queued or running workTreat as an expected user-flow outcome; retry only with a new request.
ERR_NATIVE_OPERATION_FAILEDUnclassified native failureRecord sanitized context and open a reproducible bug.

Cancellation

Cancellation is settle-once on both platforms. Native code checks between decode, transform, target-size quality probes, encode, and output publication. Cancelled and failed operations remove operation-specific temporary files.

Native module unavailable

Metro reloads JavaScript but cannot add native code. Stop the application, clean when necessary, install iOS pods, and rebuild Android or iOS.

A picker URI stops working

Compress before the picker revokes temporary access. On Android, keep any persistable permission or copy the content URI into application storage. On iOS, request a materialized file URL from the picker.

Target size is not reached

The target is not a promise that every source can satisfy. Add resize bounds, choose JPEG/WebP, lower the quality ceiling, or accept the smallest generated result and enforce an application-level rejection threshold.

For support routing, see the repository support policy.

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