Camera Error:

  • This issue is on Nexus 5P emulator

When using ionic-native's camera plugin, I can open the camera, but when I finish taking a picture, it rejects with: “No image selected”

Opens Camera:


Takes a picture:

Press Checkmark:

Press Save:
Rejected: No image selected

My camera options:

const DIMENSION = 250;
const options: CameraOptions = {
  quality: 90,
  sourceType: this.camera.PictureSourceType.CAMERA,
  destinationType: this.camera.DestinationType.DATA_URL,
  encodingType: this.camera.EncodingType.JPEG,
  mediaType: this.camera.MediaType.PICTURE,
  correctOrientation: true,
  allowEdit: true,
  targetWidth: DIMENSION,
  targetHeight: DIMENSION
};

hi, @AmitMY

try below code

const DIMENSION = 250;
var options = {
    quality: 100,
    sourceType: this.camera.PictureSourceType.CAMERA,
    saveToPhotoAlbum: false,
    correctOrientation: true,
    targetWidth: DIMENSION,
    targetHeight: DIMENSION
  };
 
  // Get the data of an image
  this.camera.getPicture(options).then((imagePath) => {
    // Special handling for Android library
    if (this.platform.is('android') && sourceType === this.camera.PictureSourceType.PHOTOLIBRARY) {
      this.filePath.resolveNativePath(imagePath)
        .then(filePath => {
          let correctPath = filePath.substr(0, filePath.lastIndexOf('/') + 1);
          let currentName = imagePath.substring(imagePath.lastIndexOf('/') + 1, imagePath.lastIndexOf('?'));
          this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
        });
    } else {
      var currentName = imagePath.substr(imagePath.lastIndexOf('/') + 1);
      var correctPath = imagePath.substr(0, imagePath.lastIndexOf('/') + 1);
      this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
    }
  }, (err) => {
    this.presentToast('Error while selecting image.');
  });

thanks,

1 Like

I tested your getPicture and it did respond, so I removed each property from my options until I get it working, using your options as a reference.

It turns out, allowEdit: true, was causing the problem. Removed that, everything works fine.

Thanks so much

@AmitMY

If your issue was resolved mark as a solution.

thanks

1 Like

In my case i need use allow edit, could you post of others method that you use?