Search code examples
androidionic-frameworkcordova-plugins

allowEdit in camera plugin returns original image


I'm trying to allow users to edit images with cordova-plugin-camera.

here is my code:

var options = {
    quality: 100,
    destinationType: Camera.DestinationType.FILE_URI,
    sourceType: Camera.PictureSourceType[type], // CAMERA or PHOTOLIBRARY
    allowEdit: true,
    targetWidth: 250,
    targetHeight: 350
};
navigator.camera.getPicture(function (imageURI) {
    $scope.imagesrc = imageURI;
    $scope.$apply();
}, function (err) {
    alert(err);
}, options);

The image returns without the edit on android device (lenovo A850).

I tried to update the version and reinstall.


Solution

  • allowEdit is unpredictable on Android and it should not be used! The Android implementation of this plugin tries to find and use an application on the user's device to do image cropping. The plugin has no control over what application the user selects to perform the image cropping and it is very possible that the user could choose an incompatible option and cause the plugin to fail. This sometimes works because most devices come with an application that handles cropping in a way that is compatible with this plugin (Google Plus Photos), but it is unwise to rely on that being the case. If image editing is essential to your application, consider seeking a third party library or plugin that provides its own image editing utility for a more robust solution.

    https://github.com/apache/cordova-plugin-camera