No image dimensions provided from capture
Describe the bug When capturing an image, I would expect there to be a height and width value returned, yet I only get the following:
{"name": "8AEEEE42-E902-4B6D-B00D-FBF68AF0A15D-1696-000003A7ECB1B040.jpg", "size": 1943477, "uri": "file:///private/var/mobile/Containers/Data/Application/6D9CE0E0-B496-41AF-8EF0-F4C7506AC7BF/tmp/8AEEEE42-E902-4B6D-B00D-FBF68AF0A15D-1696-000003A7ECB1B040.jpg"}
To Reproduce Steps to reproduce the behavior:
- Create Camera
- call
capture - Notice no
widthorheightpassed back.
Expected behavior
There should be width and height passed back, it's a fundamental part of a camera library, surely?
Smartphone (please complete the following information):
- Device: iPhone XR
- OS: ios 17.2
Took a dive on the native code on the android side, since it might be related to your usecase.
From the android native code: https://github.com/teslamotors/react-native-camera-kit/blob/master/android/src/main/java/com/rncamerakit/CKCamera.kt
...
// ImageCapture
imageCapture = ImageCapture.Builder()
.setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
// We request aspect ratio but no resolution to match preview config, but letting
// CameraX optimize for whatever specific resolution best fits our use cases
.setTargetAspectRatio(screenAspectRatio)
// Set initial target rotation, we will have to call this again if rotation changes
// during the lifecycle of this use case
.setTargetRotation(rotation)
.build()
Seems like a lack of support for this feature than a bug. The resolutions are automatically decided by native libraries, and there isnt any public methods that return the resolution (least I couldnt find any)
You might have to do a workaround and get the resolutions from the captured temporary jpeg instead
You right @alexstanbury. height/width are implemented on Android, not yet on iOS.
https://github.com/teslamotors/react-native-camera-kit/blob/master/src/types.ts
export type CaptureData = {
uri: string;
name: string;
// Android only
id?: string;
path?: string;
height?: number;
width?: number;
// iOS only
size?: number;
};
I pushed a PR to get that added 👍