Setting ratios in <Camera> on iOS

I am in the process of transitioning from ImagePicker to the new Camera component in my app.

First, the good stuff. There is a very nice example in the documentation that I just copied and pasted into my screen component and I was able to use that as the basis for my customizations. Was easy to add custom review/retake functionality and understand in general how it works. Feels a lot more pro to have a component embedded in my views vs. having the off-the-shelf image picker slide up. Kudos!

Now, the cavil. It seems to me that ImagePicker defaulted to a 3:4 image ratio (1.33) and the Camera component defaults to 3:5 (1.66). Without realizing it I had been sort of building my app around 3:4 images and I want to get the Camera component to to capture at that ratio.

However, according to the documentation, on iOS the ‘ratio’ property is ignored. So how to accomplish this? Thanks!

Here’s what I’m doing now, to not avail:

    <Camera
      style={styles.camera}
      type={this.state.type}
      autofocus={Camera.Constants.AutoFocus.on}
      flashMode={Camera.Constants.FlashMode.off}
      ratio={'5:3'}
      ref={ref => { this.camera = ref }}
    >

That generates an image with dimensions of 1080x1780, which is a 1.648 ratio.

1 Like

ah! figured it out. the ratio will match the dimensions of the view you place the Camera component in. So I changed the style of the camera to

camera: {
width:screenWidth,
height: screenWidth*1.33
},

and now the image comes through as 1080x1438, which is 1.33.

1 Like

Hello, i am trying to have 1:1 ratio, but it always 3:4 when uploaded to my server. This is my code

<Camera
camera
style={{ width: width, height: width }}
type={ this.state.cameraType }
ref={ref => { this.camera = ref; }}
ratio={‘1:1’}>