code: function resizeImageBase64 (successCallback, errorCallback, file, targetWidth, targetHeight) {
      fileIO.readBufferAsync(file).done(function (buffer) {
          var strBase64 = encodeToBase64String(buffer);
          var imageData = 'data:' + file.contentType + ';base64,' + strBase64;
  
          var image = new Image(); /* eslint no-undef : 0 */
          image.src = imageData;
  
          image.onload = function () {
              var ratio = Math.min(targetWidth / this.width, targetHeight / this.height);
              var imageWidth = ratio * this.width;
              var imageHeight = ratio * this.height;
              var canvas = document.createElement('canvas');
  
              canvas.width = imageWidth;
              canvas.height = imageHeight;
  
              var ctx = canvas.getContext('2d');
              ctx.drawImage(this, 0, 0, imageWidth, imageHeight);
  
              // The resized file ready for upload
              var finalFile = canvas.toDataURL(file.contentType);
  
              // Remove the prefix such as "data:" + contentType + ";base64," , in order to meet the Cordova API.
              var arr = finalFile.split(',');
              var newStr = finalFile.substr(arr[0].length + 1);
              successCallback(newStr);
          };
      }, function (err) { errorCallback(err); });
  }
docs: Because of asynchronous method, so let the successCallback be called in it.