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
angular cordova ionic-framework ionic2 ionic3


source to share


No one has answered this question yet

Check out similar questions:

nine
Not allowed to load local resource: ionic 3 android
6
Working with non-ionic native plugins in Ionic 2
2
Ionic Camera plugin works in Android app but doesn't work in mobile browser?
2
@ ionic-native / camera vs. @ ionic-native / media-capture
2
Ionic CallNumber Native Cordova Plugin Not Working - Ionic 3, Angular 4
1
popTo doesn't work in ionic
1
Ionic Native Date Picker not working on Android
1
Camera plugin on Windows Phone creates square images
0
Ionic native camera plugins conflict
0
file upload using IONIC native



All Articles
Loading...
X
Show
Funny
Dev
Pics