4

Q) Is there a way to force the aspect ratio of the camera via the Cordova plugin?

Details:
I'm using the Cordova camera plugin to take a photo.

I am trying to force the resolution of 1366 x 768.

The issue is that the supplied parameters for width and height seem to not have any effect unless the camera ratio is first set up using the settings in the camera app itself on the device.

I.e. if the device is set up for 4:3 photos, then no matter what I do in the options, the photos are always 4:3.

Here's the code I'm currently using:

  Camera.getPicture({
      sourceType: 1,
      destinationType: 0,
      encodingType: 0,
      saveToPhotoAlbum: false,
      allowEdit: false,
      quality: 75,
      correctOrientation: true,
      targetWidth: 1366,
      targetHeight: 768
    }).then((imageBase64: string) => {
        resolve('data:image/jpeg;base64,' + imageBase64);
    }, (error) => {
      resolve(null);
  });  
Dave
  • 4,621
  • 7
  • 40
  • 56
  • I know that in android, the camera ratio must belong to a list of available possible ratio that you can obtain by doing in Android Java: `mCamera.getParameters().getSupportedPreviewSizes();` (`mCamera` being a `Camera` object) , see: http://stackoverflow.com/questions/19577299/android-camera-preview-stretched. This does not answer fully your question but it does have an impact on it, because if one tries other sizes parameters than the supported ones, the image outcome gets really messy. – nyluje Dec 01 '16 at 15:28
  • Did you manage to figure this out? I have the same issue. – Richard May 29 '17 at 10:10

0 Answers0