Set camera width and height phonegap camera

android, cordova, javascript, phonegap-plugins

Solution

Try this one my friend. remove `allowEdit : true`

camera: function() {
        navigator.camera.getPicture(onSuccess, onFail, {
            quality: 50,
            targetWidth: 512,
            targetHeight: 512,
            destinationType: navigator.camera.DestinationType. DATA_URL,
            saveToPhotoAlbum: true,
            correctOrientation: true
        });
    }

Problem

I am currently in the process of creating a mobile app that uses the Phonegap (Cordova) camera plugin. It correctly captures the image and displays it where I want to, but I can't seem to set the targetWidth and targetHeight options, as described. targetWidth: Width in pixels to scale image. Must be used with targetHeight. Aspect ratio remains constant. (Number) targetHeight: Height in pixels to scale image. Must be used with targetWidth. Aspect ratio remains constant. (Number) As I understand, this will change the image-width and height on output. They, however, don't seem to be working. A suggestion that I found while researching for a solution, said to use the optional parameter `allowEdit`. In this I could get the user to select a pre-set squared image. This however, doesn't seem to work either. See my code below for reference. ``` camera: function() { //Fire up the camera! navigator.camera.getPicture(onSuccess, onFail, { destinationType: Camera.DestinationType.DATA_URL, allowEdit: true, targetWidth: 512, targetHeight: 512 }); }, ``` Neither of the attemps succeeded in what I wanted; a fixed width and height for the image captured. How can I set the image width and height on this image?

Original source

Related problems