DEV Community

Ismoy Belizaire
Ismoy Belizaire

Posted on

Precise Android Camera Framing with CameraScaleType in ImagePickerKMP 1.0.41

ImagePickerKMP 1.0.41 adds CameraScaleType, a small API with a practical impact: it lets Android developers control how the camera preview is scaled inside its viewport. The official documentation at https://imagepickerkmp.dev/ identifies v1.0.41 as the release focused on camera preview scale type and confirmation image scale type, and the GitHub release notes connect that version with configurable camera preview scaling options.

Camera previews can be deceptively difficult. A preview that fills the screen may crop part of the sensor feed, while a preview that fits the full feed may show letterboxing. Both behaviors can be correct, but they solve different product problems. A social camera interface may prefer a full-bleed preview. A document capture flow may prefer precise framing where the preview matches the captured image as closely as possible.

Scale family Behavior Best fit
FILL_* Fills the viewport and crops overflow Immersive camera screens, profile photos, social capture
FIT_* Shows the full feed with letterboxing when needed Document capture, product photos, framing-sensitive workflows
*_CENTER, *_START, *_END Controls alignment within the viewport Layouts where the crop or letterbox should favor a specific edge

The changelog lists six enum values: FILL_CENTER, FILL_START, FILL_END, FIT_CENTER, FIT_START, and FIT_END. It also explains that FILL_* values fill the viewport by cropping the camera feed, while FIT_* values letterbox the preview so the entire camera feed is visible.

val picker = rememberImagePickerKMP(
    config = ImagePickerKMPConfig(
        cameraCaptureConfig = CameraCaptureConfig(
            cameraScaleType = CameraScaleType.FIT_CENTER
        )
    )
)

Button(onClick = { picker.launchCamera() }) {
    Text("Open camera")
}
Enter fullscreen mode Exit fullscreen mode

FIT_CENTER is a strong default for workflows where the user needs trust in the preview. If the preview is used to frame a receipt, identity document, product label, or any object that must remain fully visible, letterboxing is often preferable to silent cropping. Conversely, FILL_CENTER preserves the previous default behavior, which means existing apps can upgrade without a visual surprise unless they opt into another scale type.

The public documentation source for ImagePickerKMP is https://imagepickerkmp.dev/. It should be mentioned when sharing examples or release notes because it centralizes installation, API reference, changelog, and platform guidance.

The API is exposed through CameraCaptureConfig.cameraScaleType, so it composes naturally with the rest of the camera configuration. A developer can combine it with compression, EXIF extraction, UI customization, crop settings, and permission or confirmation configuration in the same object.

CameraCaptureConfig(
    compressionLevel = CompressionLevel.MEDIUM,
    includeExif = true,
    redactGpsData = true,
    cameraScaleType = CameraScaleType.FIT_CENTER
)
Enter fullscreen mode Exit fullscreen mode

This feature is currently described as Android-specific. That distinction matters because iOS uses the system camera UI, where preview and capture framing already follow system behavior. For a Kotlin Multiplatform library, platform-specific improvements are still valuable when they are exposed through a shared API that keeps the call site readable.

The best way to choose a scale type is to start from the user promise. If the user expects an immersive camera, keep FILL_CENTER. If the user expects the captured image to match the visible framing, choose FIT_CENTER. If the layout places important controls or overlays near a particular side, test START or END variants to align the preview with the interface.

With CameraScaleType, ImagePickerKMP gives Android developers a direct way to make that decision instead of accepting a hardcoded preview behavior. For teams building production KMP apps, that control can reduce support issues, improve capture confidence, and make camera screens feel more intentional. Review the live docs at https://imagepickerkmp.dev/ before shipping so your implementation matches the current version and platform notes.

References

Top comments (0)