I am using Ionic3 with the ionic-native camera plugin.
I have the following:
ts
let height: number = 720;
let width: number = 1440;
let options = {
sourceType: pictureSourceType,
destinationType: Camera.DestinationType.FILE_URI,
quality: 50,
targetWidth: width,
targetHeight: height,
correctOrientation: true,
encodingType: Camera.EncodingType.JPEG,
allowEdit: false
}
if (pictureSourceType === Camera.PictureSourceType.SAVEDPHOTOALBUM) {
options.correctOrientation = false;
options.allowEdit = true;
}
Camera.getPicture(options).then((imageURI) => {
if (this.platform.is('ios')) {
Crop.crop(imageURI, { quality: 100 }).then(newPath => {
return this.toBase64(newPath).then((base64Img) => {
this.base64Image = base64Img;
}).catch((error) => {
console.error("ERROR -> " + JSON.stringify(error));
alert("ERROR: " + JSON.stringify(error));
});
});
} else if (this.platform.is('android')) {
imageURI = 'file://' + imageURI;
Crop.crop(imageURI, { quality: 100 }).then(newPath => {
return this.toBase64(newPath).then((base64Img) => {
this.base64Image = base64Img;
}).catch((error) => {
console.error("ERROR -> " + JSON.stringify(error));
alert("ERROR: " + JSON.stringify(error));
});
});
}
}, (error) => {
console.error("CAMERA ERROR -> " + JSON.stringify(error));
// alert("CAMERA ERROR: " + JSON.stringify(error));
}
).catch((error) => {
console.error("ERROR getPicture -> " + JSON.stringify(error));
alert("ERROR getPicture: " + JSON.stringify(error));
});
As you can see above, the height is set to 720 and the width to 1440. However, when I take a photo, the aspect ratio is square, i.e. it is the same height as width.
I think the issue may be related to the Crop.
Please can anyone advise how to set the aspect ratio?
Thanks