> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rebellapp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# my.compressImage

> Compress an image file.

Use this API to reduce the file size of an image.

## Parameters

| Property      | Type     | Required | Description                                                                                                                                    |
| ------------- | -------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| apFilePaths   | Array    | Yes      | Array of image paths to compress                                                                                                               |
| compressLevel | Number   | No       | Image quality after compression: `0` (low), `1` (medium), `2` (high), `4` (depends on network — Wi-Fi is high, otherwise medium); default: `4` |
| success       | Function | No       | Callback with compressed paths                                                                                                                 |
| fail          | Function | No       | Callback on failure                                                                                                                            |
| complete      | Function | No       | Callback that always executes                                                                                                                  |

## Success Callback

| Property    | Type  | Description                |
| ----------- | ----- | -------------------------- |
| apFilePaths | Array | Paths to compressed images |

## Code Example

```javascript theme={null}
my.compressImage({
  apFilePaths: ['/local/path/image.jpg'],
  compressLevel: 2,
  success: (res) => {
    console.log('Compressed:', res.apFilePaths);
  }
});
```

## Error Codes

| Code | Description                                             |
| ---- | ------------------------------------------------------- |
| 2    | Compress failed: failed to compress all images          |
| -    | Invalid parameter: failed to compress one of the images |
