Cordova

Cordova Crop Image Plugin

Crop Image after clicking using camera or selecting image.

It crops the images in square shape.

This cordova project uses two plugins:

  1. Cordova Camera Plugin — https://github.com/apache/cordova-plugin-camera

  2. Cordova Crop Image Plugin — https://github.com/jeduan/cordova-plugin-crop

The Camera plugin is combined with the Crop Image Plugin by putting the Cop Image Plugin Code within the success callback of Camera Plugin Code.

  /*Camera Plugin Code*/
  navigator.camera.getPicture(onSuccess, onFail, {
      quality: 50,
      destinationType: Camera.DestinationType.FILE_URI
  });

  function onSuccess(imageData) {
       console.log(imageData);
       
       /*Crop Image Plugin Code*/
       plugins.crop(function success (data) {
          console.log(data);
          var image = document.getElementById('myImage');
          image.src = data;
       }, 
       function fail () {

       }, imageData, {quality:100});
  }

 function onFail(message) {
    alert('Failed because: ' + message);
 }



This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow