Skip to content


Capacitor plugin for compressing files.


This project is available as Sponsorware.

Sponsorware is a release strategy for open-source software that enables developers to be compensated for their open-source work with fewer downsides than traditional open-source funding models. (Source)

This means...

  • The source code will be published as soon as the funding goal is reached.
  • Any sponsor with a sponsorware tier gets immediate access to our sponsors-only repository and can start using the project right away.


This project is licensed under the terms of the MIT license.
However, we kindly ask you to respect our fair use policy:

  • Please don't distribute the source code of the sponsors-only repository. You may freely use it for public, private or commercial projects, privately fork or mirror it, but please don't make the source code public, as it would counteract the sponsorware strategy.
  • If you cancel your subscription, you're automatically removed as a collaborator and will miss out on all future updates. However, you may use the latest version that's available to you as long as you like.


A working example can be found here: capawesome-team/capacitor-plugin-demo



See Getting started with Insiders and follow the instructions to install the plugin.



This plugin will use the following project variables (defined in your app’s variables.gradle file):

  • $androidxDocumentFileVersion version of androidx.documentfile:documentfile (default: 1.0.1)


No configuration required for this plugin.


import { FileCompressor } from '@capawesome-team/capacitor-file-compressor';

const compressImage = async () => {
  const { path } = await FileCompressor.compressImage({
    mimeType: 'image/jpeg',
    path: 'content://',
    quality: 0.7,
  return path;



compressImage(options: CompressImageOptions) => Promise<CompressImageResult>

Compress an image.

Only png, jpeg, and webp images are supported.

Attention: The exif data of the image is lost during compression.

Param Type
options CompressImageOptions

Returns: Promise<CompressImageResult>

Since: 5.0.0



Prop Type Description Since
path string The path of the compressed file. Only available on Android and iOS. 5.0.0
blob Blob The blob of the compressed file. Only available on Web. 5.0.0


Prop Type Description Default Since
blob Blob The blob of the file to compress. Only available on Web. 5.0.0
mimeType string The mime type of the compressed file. On Android, only image/jpeg and image/webp are supported. On iOS, only image/jpeg is supported. On Web, only image/jpeg and image/webp are supported. 'image/jpeg' 5.0.0
path string The path of the file to compress. Only available on Android and iOS. 5.0.0
quality number The quality of the resulting image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality). 0.6 5.0.0