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
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 |