Search code examples
androidiosionic-frameworkcamera

Does Ionic Camera Preview plugin provide a full-quality pic?


There are 2 ways (that I'm aware of) to capture images/videos from the camera in an ionic app:

  • Native camera app
  • 'Camera Preview' library

The first option I know will allow users to maximise the potential of the camera (quality, megapixels etc.), but I need the flexibility of adding an overlay (basically I need the flexibility of the second option).

Question

In the docs I can only see the ability to see a 'quality' argument as part of the 'takePicture' call, how would a maximum of 100 here compare to the quality of a pic I'd have got from the native app?

I know this is called 'camera preview' but ideally I need it to be the best image quality the camera's capable of capturing (same as the native app).

https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview


Solution

  • Take snapshot of the camera preview. The resulting image will be the same size as specified in startCamera options. The argument quality defaults to 85 and specifies the quality/compression value: 0=max compression, 100=max quality.

    CameraPreview.takePicture({width:640, height:640, quality: 100}, function(base64PictureData|filePath) {  
    
      // One simple example is if you are going to use it inside an HTML img src attribute then you would do the following:
      imageSrcData = 'data:image/jpeg;base64,' + base64PictureData;
      console.log(imageSrcData);
    });
    

    For More Info Check Documentations.