---
name: "chooseImage"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.0.1" }
  - { name: "@ray-js/ray", version: "0.3.23" }
platform:
  - "iOS"
  - "Android"
async: true
---

## chooseImage

> [VERSION] BaseKit >= 2.0.1 | @ray-js/ray >= 0.3.23

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Select images from the local album or take photos with the camera. You can use chooseMedia instead.
Permissions: [scope.camera, scope.writePhotosAlbum]
Related API: [chooseMedia]

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `count` | `number` | No | `9` | `2.0.1` | Maximum number of images to select. Note: On Android 13 and above, the system image picker is used and this field has no effect |
| `imageType` | `string` | No | - | `3.35.7` | Filter image types; pass 'gif' to show only GIFs, pass 'image' to show non-GIF static images; if omitted or empty, no filtering by default |
| `sizeType` | `string[]` | No | - | `2.0.1` | Image size type; pass 'original' for the original image, 'compressed' for a compressed image |
| `sourceType` | `string[]` | No | - | `2.0.1` | Source for selecting images ['album', 'camera'] |
| `disableDismissAnimationAfterSelect` | `boolean` | No | - | `3.11.3` | Whether to disable the animation when closing the interface after canceling image selection |
| `complete` | `() => void` | No | - | - | Completion callback (executed on both success and failure) |
| `success` | `(params: Object) => void` ↓see below | No | - | - | Callback on successful API call |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### success callback parameters

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `tempFilePaths` | `string[]` | `3.2.6` | List of local temporary image file paths (local paths) |
| `tempFiles` | `TempFileCB[]` | `3.2.6` | List of selected image file objects, including the local temporary file path path and file size size (in bytes) |

#### fail callback parameters

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` | Error message |
| `errorCode` | `string \| number` | Error code |
| `innerError` | `Object` | Error extension |

##### fail(params).innerError properties

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string \| number` | Error extension code |
| `errorMsg` | `string` | Error extension message |


### Referenced Types

##### `interface` TempFileCB

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `path` | `string` | `3.2.6` | Local temporary file path (local path) |
| `size` | `number` | `3.2.6` | Local temporary file size, in bytes (B) |


### Examples

#### Demo

```tsx
import { chooseImage } from '@ray-js/ray'

// Select images from the album or take photos (invokes the system picker; manual selection required)
chooseImage({
  count: 1,
  sizeType: ["compressed"],
  sourceType: ["album", "camera"],
  success: data => console.log("Selected images:", data.tempFilePaths),
  fail: error => console.error(error),
});
```
