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

# Gallery picker

> Let users pick photos and videos with the native gallery on Android and iOS

[See the platform support matrix](https://filekit.mintlify.site/platform-support.md#filekit-dialogs)

Pass `FileKitType.Image`, `Video`, or `ImageAndVideo` to the file picker. On Android and iOS it opens the system photo picker; on other targets it opens a file dialog filtered to media files.

## Usage

```kotlin Compose theme={null}
val launcher = rememberFilePickerLauncher(
    type = FileKitType.Image,
    onError = { failure -> showError(failure.message) },
) { image ->
    // image is a PlatformFile, or null when the user cancelled
}

Button(onClick = { launcher.launch() }) {
    Text("Pick a photo")
}
```

```kotlin Suspend API theme={null}
val image: PlatformFile? = FileKit.openFilePicker(type = FileKitType.Image)
```

The result is `null` when the user cancels. Failures go to `onError` in Compose, or are thrown as a `FileKitDialogException` by the suspend API. See [Results and errors](https://filekit.mintlify.site/dialogs/error-handling.md).

Every [file picker option](https://filekit.mintlify.site/dialogs/file-picker.md#options) applies, including the state-tracking modes.

## Try it

This is the FileKit sample running in your browser. Choose images, videos, or both, switch the selection mode, then open a file to inspect its metadata. In a browser the picker is a file input filtered to media files.

[Open in a new tab ↗](https://vinceglb.github.io/FileKit/?demo=gallery-picker)

## What users see

| Platform | Dialog |
| - | - |
| Android | The system [Photo Picker](https://developer.android.com/training/data-storage/shared/photopicker). If the device has none, FileKit opens the document picker filtered by `image/*` or `video/*`. |
| iOS | [`PHPickerViewController`](https://developer.apple.com/documentation/photokit/selecting-photos-and-videos-in-ios). FileKit copies each selected item to a temporary directory before returning it. |
| macOS, JVM, Linux native, Windows native | The regular file dialog, filtered to `png`, `jpg`, `jpeg`, `gif`, `bmp` for images and `mp4`, `mov`, `avi`, `mkv`, `webm` for videos. |
| Web | `<input type="file">` with `accept` set to `image/*`, `video/*`, or both. |

![The Android Photo Picker](https://developer.android.com/static/images/training/data-storage/kotlin-picker.gif)

## Limit the number of items

Use `FileKitMode.Multiple(maxItems)` with a value from `1` to `50`. The same `mode` works on `rememberFilePickerLauncher`:

```kotlin theme={null}
val media: List<PlatformFile>? = FileKit.openFilePicker(
    type = FileKitType.ImageAndVideo,
    mode = FileKitMode.Multiple(maxItems = 5),
)
```

The iOS picker and the Android Photo Picker enforce the limit in their UI. When Android falls back to the document picker, and on other targets, the dialog can't limit the selection, so FileKit keeps the first `maxItems` files.

> [!TIP]
>
> iOS can return photos as HEIC, which some image decoders and servers can't read. In `iosMain`, pass `FileKitDialogSettings(assetRepresentationMode = FileKitAssetRepresentationMode.Compatible)` as `dialogSettings` so iOS transcodes them to a more compatible format.

## Related

* [Camera picker](https://filekit.mintlify.site/dialogs/camera-picker.md) to take a new photo.
* [Coil](https://filekit.mintlify.site/integrations/coil.md) to display the picked image.
* [Image and video utilities](https://filekit.mintlify.site/core/image-and-video-utils.md) to compress or resize it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.