Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No image dimensions provided from capture #641

Open
alexstanbury opened this issue Feb 2, 2024 · 3 comments
Open

No image dimensions provided from capture #641

alexstanbury opened this issue Feb 2, 2024 · 3 comments

Comments

@alexstanbury
Copy link

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:

  1. Create Camera
  2. call capture
  3. Notice no width or height passed 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
@zenovak
Copy link

zenovak commented Feb 7, 2024

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

@DavidBertet
Copy link
Contributor

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;
};

@DavidBertet
Copy link
Contributor

I pushed a PR to get that added 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants