Create image thumbnail

How can i create an image thumbnail from ngCordova image-picker and camera?

You can do it with the cordova-plugin-camera module exclusively. See uncomment one of the sourceTypes to access your saved photos. The current sourceType accesses your camera. The targetWidth and targetHeight explicitly sets the size of the thumbnail. Its best to stick with square sizes ie targetWidth = targetHeight because when they’re not equal you may not get what you want.

var options = {
  quality: 100,
  destinationType: Camera.DestinationType.DATA_URL,
  sourceType: Camera.PictureSourceType.CAMERA,
  // sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
  // sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM, 
  allowEdit: true,
  encodingType: Camera.EncodingType.JPEG,
  targetWidth: 100,
  targetHeight: 100,
  popoverOptions: CameraPopoverOptions,
  saveToPhotoAlbum: false,

$cordovaCamera.getPicture(options).then(function(imageData) {
  var image = document.getElementById('myImage');
  image.src = "data:image/jpeg;base64," + imageData;
}, function(err) {
  // error
1 Like