
Select images with configurable aspect ratios, native integration, and an easy async API returning image bytes; integrates with UI layers via simple launcher registration and ViewModel support.
A Kotlin Multiplatform image selection library for Android, iOS and Desktop.
| Platform | Supported |
|---|---|
| Android | ✔️ |
| iOS | ✔️ |
| Desktop | ✔️ |
| Web | ❌️ |
See the releases section of this repository for the latest version.
To your build.gradle under commonMain.dependencies add:
implementation "com.wannaverse:imageselector:<version>"Important this library uses native code. You will need the additional dependencies depending on the targets you are building for:
Android under androidMain.dependencies: implementation("com.wannaverse:imageselector-android:")
iOS (ARM) under iosMain.dependencies: implementation("com.wannaverse:imageselector-iosarm64:")
iOS x64 under iosMain.dependencies: implementation("com.wannaverse:imageselector-iosx64:")
jvm: implementation("com.wannaverse:imageselector-jvm:")
Below is a sample code that you may use.
When setting up the image selector on Android, you will need to add the following to your MainActivity's onCreate function:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Add these to register the image selector
setImageSelectorActivity(this)
registerImageSelectorLauncher()
}Example ViewModel:
class AppViewModel : ViewModel() {
val image = mutableStateOf<ImageData?>(null)
fun chooseImage() = viewModelScope.launch {
image.value = selectImage()
}
}Example Composable:
@Composable
fun App(viewModel: AppViewModel = viewModel { AppViewModel() }) {
val image = remember { viewModel.image }
val bitmap = image.value?.bytes?.toImageBitmap()
Column(modifier = Modifier
.fillMaxSize()
.safeContentPadding()
) {
Button(onClick = {
viewModel.chooseImage()
}) {
Text(
text = "Select Image"
)
}
bitmap?.let {
Image(
bitmap = it,
contentDescription = null
)
}
}
}MIT LICENSE. See LICENSE for details.
Pull requests and feature requests are welcome! If you encounter any issues, feel free to open an issue.
A Kotlin Multiplatform image selection library for Android, iOS and Desktop.
| Platform | Supported |
|---|---|
| Android | ✔️ |
| iOS | ✔️ |
| Desktop | ✔️ |
| Web | ❌️ |
See the releases section of this repository for the latest version.
To your build.gradle under commonMain.dependencies add:
implementation "com.wannaverse:imageselector:<version>"Important this library uses native code. You will need the additional dependencies depending on the targets you are building for:
Android under androidMain.dependencies: implementation("com.wannaverse:imageselector-android:")
iOS (ARM) under iosMain.dependencies: implementation("com.wannaverse:imageselector-iosarm64:")
iOS x64 under iosMain.dependencies: implementation("com.wannaverse:imageselector-iosx64:")
jvm: implementation("com.wannaverse:imageselector-jvm:")
Below is a sample code that you may use.
When setting up the image selector on Android, you will need to add the following to your MainActivity's onCreate function:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Add these to register the image selector
setImageSelectorActivity(this)
registerImageSelectorLauncher()
}Example ViewModel:
class AppViewModel : ViewModel() {
val image = mutableStateOf<ImageData?>(null)
fun chooseImage() = viewModelScope.launch {
image.value = selectImage()
}
}Example Composable:
@Composable
fun App(viewModel: AppViewModel = viewModel { AppViewModel() }) {
val image = remember { viewModel.image }
val bitmap = image.value?.bytes?.toImageBitmap()
Column(modifier = Modifier
.fillMaxSize()
.safeContentPadding()
) {
Button(onClick = {
viewModel.chooseImage()
}) {
Text(
text = "Select Image"
)
}
bitmap?.let {
Image(
bitmap = it,
contentDescription = null
)
}
}
}MIT LICENSE. See LICENSE for details.
Pull requests and feature requests are welcome! If you encounter any issues, feel free to open an issue.