ImagePickerKMP support extentions now and Web

Backer ●16 ●28
calendar_today • schedule1 min read

ImagePickerKMP — New Extensions & Image Compression

Repository: ismoy/ImagePickerKMP


Overview

ImagePickerKMP now introduces powerful new extension functions and image compression features for more flexible image handling across Android, iOS and Web platforms.


Available Extension Functions

These new extensions allow you to easily convert captured or selected images into different formats — perfect for storage, UI display, graphics, or network use.

Function Returns Usage
loadBytes() ByteArray For file operations and storage
loadPainter() Painter For direct display in Compose UI
loadImageBitmap() ImageBitmap For Compose graphics operations
loadBase64() String For API calls and network transmission

Example Usage

// State variables
var showCamera by remember { mutableStateOf(false) }
var showGallery by remember { mutableStateOf(false) }
var capturedImage by remember { mutableStateOf<Painter?>(null) }
var selectedPhotos by remember { mutableStateOf<List<GalleryPhotoHandler.PhotoResult>>(emptyList()) }

// Camera with extension functions
if (showCamera) {
    ImagePickerLauncher(
        config = ImagePickerConfig(
            onPhotoCaptured = { result ->
                // Use extension functions to get different formats
                val imageBytes = result.loadBytes()        // For file operations
                val imagePainter = result.loadPainter()    // For UI display
                val imageBitmap = result.loadImageBitmap() // For graphics operations
                val imageBase64 = result.loadBase64()      // For API calls
                
                // Store the painter to display later
                capturedImage = imagePainter
                showCamera = false
            },
            onError = { showCamera = false },
            onDismiss = { showCamera = false },
            directCameraLaunch = true
        )
    )
}

// Gallery with extension functions
if (showGallery) {
    GalleryPickerLauncher(
        onPhotosSelected = { photos ->
            selectedPhotos = photos
            showGallery = false
        },
        onError = { showGallery = false },
        onDismiss = { showGallery = false },
        allowMultiple = true
    )
}

// Display captured image
capturedImage?.let { painter ->
    Image(
        painter = painter,
        contentDescription = "Captured photo",
        modifier = Modifier.size(200.dp)
    )
}

// Display selected photos
LazyColumn {
    items(selectedPhotos) { photo ->
        photo.loadPainter()?.let { painter ->
            Image(
                painter = painter,
                contentDescription = "Selected photo",
                modifier = Modifier
                    .fillMaxWidth()
                    .height(200.dp)
            )
        }
    }
}

gist: read More

Want more #mobileappdevelopment & #crossplatform deep dives?

Join 5,986+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

1 Comment

0 votes

More Posts

React Native Quote Audit - USA

kajolshah - Mar 2

AAIF Hits 10 Projects. Its CTO on What to Adopt Now and the Security Gaps Left Open

Tom Smithverified - Oct 23

How AI Is Changing Web Development, and What Developers Still Need to Understand

Daniel Decker - Nov 10

Merancang Backend Bisnis ISP: API Pelanggan, Paket Internet, Invoice, dan Tiket Support

Masbadar - Mar 13

Reelora Now Available on Indus Appstore – A New Era of Movie Discovery!

Dilip Kumar - Sep 29, 2025
chevron_left
1.4k Points • 44 Badges
San Miguel, Chile
9Posts
7Comments
I'm a passionate mobile & cross-platform developer who builds high-quality, production-ready tools a... Show more

Related Jobs

View all jobs →

Commenters (This Week)

4 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!