Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

109
Vistas
Cordova Crop Plugin

I'm currently trying to use this cordova plugin in an android app to crop images after uploading them. The README says to use it like this:

plugins.crop(function success () {

}, function fail () {

}, '/path/to/image', options)

Unfortunately I don't have much experience in JavaScript, so I tired it this way:

handleCropPress: function () {
   var oImage = this.byId("image");
   var srcImage = oImage.getSrc();

   plugins.crop(function success () {

   }, function fail () {

   }, srcImage)
}

Any ideas why it's not working? Many thanks in advance :)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

where is your getPicture code? they both should work hand in hand... try something like this..

// I assume that you have called the following after installing both cordova-plugin-camera and cordova-plugin crop, so now write an onClick event on a button to call the following line in a function

navigator.camera.getPicture(onPhotoDataSuccess, onFail, { 
    correctOrientation: true, 
    targetWidth: 1024, 
    targetHeight: 1024, 
    destinationType: destinationType.FILE_URI 
}); 

// Now in the onPhotoDataSuccess get the image url.. the one that the api is returning from destinationType.FILE_URI

function onPhotoDataSuccess(imageData) {

    plugins.crop.promise(imageData)
        .then(function success(imageFinal) {
            // Success.
            alert(imageFinal); //alert to see if you are getting the path

            var picPreviewBox = document.getElementById('picPreviewBox'); //create an img tag with src="" and assign an ID named picPreviewBox or anything you feel like and call that id in the above line

            picPreviewBox.style.display = 'block';
            // //picPreviewBox.src = "data:image/jpeg;base64," + image;
            picPreviewBox.src = imageFinal;
            //$("#picPreviewBox").html('<img src="data:image/jpeg;base64,'+image+'" width="100%"/>');

        })
        .catch(function fail(err) {
            // fail
            $.alert("Seems your phone resources are too low to proceed further");
        });

}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda