Camera plugin is working or not


#1

Hai , i want to know the camera plugin is working or depreciated ,

Can any tell , are we able use camera plugin or not

i am asking this question because, 6 month back camera plugin working properly, but their no answer i found , still camera is working or not

please help me with working camera native plugin


#2

Yes it is working fine.


#3

Thanks for the replay

i am using
@ionic-native/camera”: “4.2.0”,
“cordova-plugin-camera”: “^4.0.2”,
@ionic-native/core”: “3.6.0”,

i am getting error like “error capturing image” when captured image

please let me know dependencies of camera plugin

i am facing this issue from last 6 months


#4
"@ionic-native/camera": "^4.7.0",
"cordova-plugin-camera": "^4.0.3",
"@ionic-native/core": "4.6.0",

#5

Thank you very much i will check this versions


#6

Sure and You’re welcome.


#7

Here’s a snippet of my code. I wasn’t able to test this code, so pls use it as a reference…

Used packages:

    "@ionic-native/camera": "4.5.3",
    "@ionic-native/core": "4.5.3",
    "cordova-plugin-camera": "^4.0.2",

Example:

import { Camera, CameraOptions } from "@ionic-native/camera";
import { File } from "@ionic-native/file";

...

export class MyPage{
  private fileName: string;
  private imgSrc: any;
  private cameraOptions: CameraOptions = {
    cameraDirection: this.camera.Direction.BACK,
    correctOrientation: true,
    destinationType: this.camera.DestinationType.FILE_URI,
    encodingType: this.camera.EncodingType.JPEG,
    mediaType: this.camera.MediaType.PICTURE,
    quality: 100,
    sourceType: this.camera.PictureSourceType.CAMERA,
    targetHeight: 1280,
    targetWidth: 1280,
  };

  constructor(private camera: Camera, private file: File) { }

  public getPicture(){
      let currentName: string;
      let correctPath: string;
      this.camera.getPicture(this.cameraOptions)
          .then((imagePath) => {
            // cleaning/formatting the filename
            currentName = imagePath.substr(imagePath.lastIndexOf("/") + 1);
            -1 !== currentName.indexOf("?") ?
              currentName = currentName.substr(0, currentName.lastIndexOf("?")) :
              null;

            correctPath = imagePath.substr(0, imagePath.lastIndexOf("/") + 1);
            return this.file.resolveLocalFilesystemUrl(correctPath);
          }, (err) => {
            reject("Error while selecting image.");
          })
          .then((res: any) => {
            if (res) {
              this.fileName = currentName; // if you might need it
              this.imgSrc = res.nativeURL + currentName;
            } else {
                console.log("Couldn't resolve localFileSystemUrl");
            }
          });
      })
        .catch((err) => {
          console.error("No item selected", err);
        });
   }
}

How to get the file after using photo library