DEV Community

Ismoy Belizaire
Ismoy Belizaire

Posted on • Originally published at imagepickerkmp.dev

New ImagePickerKMP API: The easiest way to handle Camera and Gallery in Kotlin Multiplatform

Handling camera and gallery in Kotlin Multiplatform has always been difficult.

Different APIs for Android and iOS.

Permissions everywhere.

State management with booleans like showCamera and showGallery.

This changes with the new API introduced in ImagePickerKMP, which provides a cleaner, reactive, and truly multiplatform approach.


The problem with current solutions

If you have worked with KMP and media input, you have likely faced:

  • Platform-specific implementations
  • Complex permission flows
  • UI inconsistencies between Android and iOS
  • State handling with multiple flags (showCamera, showGallery, etc.)

Most existing solutions are also not designed with Compose Multiplatform as a first-class approach.


Introducing the new API: rememberImagePickerKMP

The new recommended API is:

kotlin val picker = rememberImagePickerKMP(...)

This API provides a state-driven approach that controls the entire flow.

It returns an ImagePickerKMPState, which:

  • Handles camera and gallery
  • Exposes a reactive result
  • Eliminates the need for manual UI triggers

There is no need for Render() calls or manual UI handling.

More details: https://imagepickerkmp.dev/


Launch camera or gallery

kotlin picker.launchCamera() picker.launchGallery()

Each call:

  • Opens the appropriate UI
  • Applies configuration automatically
  • Returns results reactively

You can override configuration per launch without modifying global state.


Reactive result handling

Instead of multiple callbacks:

kotlin when (val result = picker.result) { is Success -> { /* use image / } is Error -> { / handle error */ } }

The result is modeled as a sealed hierarchy:

  • Idle
  • Loading
  • Success
  • Dismissed
  • Error

This leads to a more predictable and maintainable UI.


Unified configuration

The API introduces a single configuration object:

kotlin ImagePickerKMPConfig(...)

This controls:

  • Camera behavior
  • Gallery selection (multi-select, MIME types, limits)
  • Crop options (square, circular, freeform)
  • UI customization
  • Permissions

Everything is centralized in one place.


Features

ImagePickerKMP provides:

  • Native camera (zoom, flash, rotation)
  • Gallery support (single and multiple selection)
  • Built-in crop UI
  • EXIF metadata (GPS, ISO, etc.)
  • Compression levels (LOW, MEDIUM, HIGH)
  • PDF support
  • Cloud OCR integration (Gemini, OpenAI, Claude, etc.)

Compatible with Android, iOS, Desktop, Web, and WASM.


Why this API matters

Key improvements:

  • Eliminates boolean-based state handling
  • Removes manual UI rendering
  • Fully reactive state model
  • Compose-first design
  • Supports per-launch configuration overrides
  • Cleaner and scalable architecture

Installation

kotlin implementation("io.github.ismoy:imagepickerkmp:1.0.35")

Requirements:

  • Kotlin 2.3.x
  • Compose Multiplatform 1.10+

More information: https://imagepickerkmp.dev/


Documentation

Full documentation, examples, and API reference are available at:

https://imagepickerkmp.dev/


Final thoughts

Handling media input in Kotlin Multiplatform should not require complex platform-specific logic.

This API simplifies the process and provides a consistent way to work with camera and gallery across platforms.


Discussion

  • What has been your main challenge when working with image pickers in KMP?
  • What features would you like to see next?

-———————

Top comments (0)