$ show ismoy/ImagePickerKMP
ImagePickerKMP is a Kotlin Multiplatform library (not a standalone application) that delivers production-grade media picking and barcode scanning capabilities for Android, iOS, JVM desktop, and web/JS/Wasm targets. The photo module (imagepickerkmp-photo) provides camera capture, gallery selection, image cropping, EXIF extraction with GPS redaction, configurable compression (LOW/MEDIUM/HIGH), and permission-request UI, all driven through a Compose Multiplatform API centered on rememberImagePickerKMP(). The scanner module (imagepickerkmp-scanner) provides continuous barcode/QR scanning with auto-zoom, distance warnings, batch mode, phantom-code suppression, and enterprise inactivity overlays, using ML Kit on Android and AVFoundation/Vision on iOS. A shared imagepicker-core module abstracts permissions, filesystem access, URI handling, language detection, and logging across platforms via the Kotlin expect/actual mechanism. The library is distributed as versioned Maven artifacts with a published JS bundle for web integration. Architecturally, the codebase is a modular multi-artifact Gradle project: imagepicker-core (infrastructure), imagepickerkmp-photo, and imagepickerkmp-scanner, with each module enforcing dependency boundaries (the scanner module explicitly prohibits depending on the photo module). Its design leans on config-driven API design (large nested data classes such as ImagePickerKMPConfig and ScannerBehaviorConfig with runtime validation), observable state holders (sealed Idle/Loading/Success/Dismissed/Error states backed by Compose mutableStateOf), and event-driven scanner orchestration. Platform-specific behavior is cleanly isolated through expect/actual: Android uses CameraX, ActivityResultContracts, and ExifInterface; iOS uses UIImagePickerController, PHPicker, PhotosUI, and CoreGraphics; desktop/web use file choosers or documented no-op stubs where camera hardware is unavailable. Localization spans 14 languages via YAML translation files and the i18nkonfig plugin, and CI (GitHub Actions) runs detekt static analysis, Kover coverage verification with a 90% line minimum, unit tests across commonTest/androidUnitTest/iosTest, and publishes coverage to Codecov. Maintenance is active: a recent commit history on the develop branch, one open issue, zero Dependabot alerts, and continuously updated Kotlin 2.x / Compose Multiplatform versions indicate steady upkeep. Known rough edges include intentionally blank PlatformPrewarm files, crop implementation stubs on JS/WASM, a handful of placeholder tests asserting true, duplicated permission-handling logic across photo/scanner modules, and a potentially stale build-and-bundle.sh referencing an old JS build path. Overall, this is a well-crafted, professionally engineered KMP library with genuinely reusable cross-platform abstractions and strong test discipline; it is a solid reference for Kotlin Multiplatform architecture and Compose-based camera/scanning UX.
The LLM identified 5 files worth highlighting for reuse:
A self-contained pure-Kotlin controller that determines camera zoom levels from barcode bounding-box size and distance estimates, smoothing zoom changes to avoid hunting. It is fully UI-independent, has dedicated unit tests (ScannerAutoZoomControllerTest), and can be extracted into any continuous-scanning camera application needing distance-aware auto-zoom.
Encapsulates the business rules deciding whether a scanned barcode should be emitted: suppression of phantom/duplicate reads, stability windows, distinctness from the previous scan, and batch-mode accumulation. It is a pure logic class decoupled from the camera and UI, tested in isolation, and reusable in any high-throughput scanner system requiring debouncing and duplicate suppression.
A clean mapper interface converting native barcode formats (ML Kit on Android, AVMetadataObject types on iOS) into a canonical domain BarcodeFormat enum, with platform-specific implementations injected at runtime. Demonstrates an extensible adapter pattern that decouples domain models from vendor SDKs; usable in any multiplatform project bridging vendor types to a stable domain model.
Pure geometry utilities for aspect-ratio-preserving crop rect computation, including fitting a crop rectangle to a target aspect ratio while clamping to image bounds. Completely platform-agnostic, thoroughly unit-tested alongside CropUtils and ResizeCropRect, and directly extractable into any image-editing or cropping UI as a reusable math core.
A small, well-factored platform-neutral logging abstraction (MediaLogger interface, LogLevel enum, console implementation) shared across all modules. It demonstrates interface-segregation and level-filtering patterns that any Kotlin Multiplatform project can lift directly without framework dependencies or internal coupling.