Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

112
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda