NativeScript / nativescript-camera

NativeScript plugin to empower using device camera.
Apache License 2.0
92 stars 47 forks source link

Returning Null Image on iOS #102

Closed tuckerjt07 closed 6 years ago

tuckerjt07 commented 6 years ago

Which platform(s) does your issue occur on?

iPad 11.2.6

Please, provide the following version numbers that your issue occurs with:

Describe the steps to reproduce it.

Open the camera on my device and inspect the returned ImageAsset object. There is no image data, width, height, etc. are all null. Attempting to output to a Base64String also results in a null value.

Is there any code involved?


    camera.takePicture(_cameraOptions)
      .then((imageAsset: ImageAsset) => {
        if (device.isAndroid) {
          return callbackFunction(imageAsset, token, environment, newSession, this);
        } else {
          const _imageSource = new imageSource.ImageSource();
          return _imageSource.fromAsset(imageAsset).then((result) => {
            console.log("Size: " + imageAsset.options.width + "x" + imageAsset.options.height);
            console.log(result.toBase64String('jpg', 100));
          });```
lini commented 6 years ago

I was not able to reproduce the issue in the camera using an iPad running iOS 11.2. I tried using the demo app from this repo and pasted the code you gave in the main-page.ts file. The only thing I changed was the _cameraOptions parameter and set it to:

{ 
  width: 300,
  height: 300,
  keepAspectRatio: true,
  saveToGallery: false
}

I got the expected output:

CONSOLE LOG file:///app/main-page.js:23:28: Size: 300x300
CONSOLE LOG file:///app/main-page.js:24:28: /9j/4AAQSkZJRgABAQAAkACQAAD/4QCMRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAACQAAAAAQAAAJAAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAAligAwAEAAAAAQAAAyAAAAAA/+0AOFBob3Rvc2hvcCAzLjAAOEJJTQQEAAAAAAAAOEJJTQQlAAAAAAAQ1B2M2Y8AsgTpgAmY7PhCfv/AABEIAyACWAMBEQACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE

I suggest you try using the demo app to test and updating to the latest NativeScript version(4.0) if you have not done so already.

nsplugins commented 6 years ago

I close this issue due to inactivity.