Ionic Native Camera target width not working
I am using Ionic3 with an ionic camera plugin .
I have the following:
c
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 equal 720
and the width is to 1440
. However, when I take a photo, the aspect ratio is square, meaning it has the same height as the width.
I think the problem may be related to Crop
.
Please can you advise how to set the aspect ratio?
thank
+3
source to share
No one has answered this question yet
Check out similar questions: