metalaureate metalaureate - 5 months ago 25
iOS Question

Cordova returns photo in landscape with black region top and bottom

Is there a way to configure the Cordova camera plugin to return photos without the black bands outside of the target height?

E.g.,
enter image description here

is returned when options set thus:

var options = {
quality: 100,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 800,
targetHeight: 1200,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
correctOrientation: true
};
$cordovaCamera.getPicture(options).then(function (imageURI) {});


I have tried removing the
targetWidth
and
targHeight
parameters. One issue that you can't know ahead of time whether the photo is landscape or portrait.

This is a dupe of this question that was never answered a year ago: Phonegap Camera returns photo with black bars

Answer

Don't use the allowEdit option or set it to false

When you use allowEdit: true, it takes you to a crop screen that will create a square image, if you don't zoom the image to crop it, it will add that black regions on top and bottom to make the image a square