How to use the ionic-native.Camera.PictureSourceType function in ionic-native

To help you get started, we’ve selected a few ionic-native examples, based on popular ways it is used in public projects.

github thomasgazzoni / ng2-platform / src / camera / camera.ionic.ts View on Github external
.create((observer: Observer<string>) => {

                const cameraOptions: CameraOptions = {
                    quality: 50,
                    destinationType: options && options.returnBase64 ? Camera.DestinationType.DATA_URL : Camera.DestinationType.FILE_URI,
                    sourceType: Camera.PictureSourceType.CAMERA,
                    encodingType: Camera.EncodingType.JPEG,
                    correctOrientation: true,
                    // saveToPhotoAlbum: false,
                };

                this.setOptions(cameraOptions, options);

                Camera.getPicture(cameraOptions)
                    .then((imageData) => {

                        // imageData is either a base64 encoded string or a file URI
                        // If it's base64:
                        // let base64Image = 'data:image/jpeg;base64,' + imageData;

                        // console.debug('imageData', imageData);
github aaronksaunders / firebaseStorage2 / src / pages / home / home.ts View on Github external
doGetPicture() {

  // TODO:
  // get picture from camera

  console.log(Device)
  let imageSource = (Device.isVirtual ? Camera.PictureSourceType.PHOTOLIBRARY : Camera.PictureSourceType.CAMERA);

  Camera.getPicture({
    destinationType: Camera.DestinationType.FILE_URI,
    sourceType: imageSource,
    targetHeight: 640,
    correctOrientation: true
  }).then((_imagePath) => {
    alert('got image path ' + _imagePath);
    // convert picture to blob
    return this.makeFileIntoBlob(_imagePath);
  }).then((_imageBlob) => {
    alert('got image blob ' + _imageBlob);

    // upload the blob
    return this.uploadToFirebase(_imageBlob);
  }).then((_uploadSnapshot: any) => {
github aaronksaunders / ionic2firebase3 / app / pages / home / home.ts View on Github external
doTakePicture() {
    Camera.getPicture({
      destinationType: Camera.DestinationType.FILE_URI,
      sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
      targetWidth: 640,
      correctOrientation: true
    }).then((imageData) => {
      // imageData is a file path

      this.doImageResize(imageData, (_data) => {
        this.ngZone.run(() => {
          this.currentImage = _data
          this.images['thumb'] = _data
        })
      }, 640)

      // get the path correct for android devices
      if (this.platform.is("android")) {
        imageData = "file://" + imageData
      }
github aaronksaunders / firebaseStorage2 / app / pages / home / home.ts View on Github external
doGetPicture() {
    // TODO:
    // get picture from camera
    Camera.getPicture({
      destinationType: Camera.DestinationType.FILE_URI,
      sourceType: Camera.PictureSourceType.CAMERA,
      targetHeight: 640,
      correctOrientation: true
    }).then((_imagePath) => {
      alert('got image path ' + _imagePath);
      // convert picture to blob
      return this.makeFileIntoBlob(_imagePath);
    }).then((_imageBlob) => {
      alert('got image blob ' + _imageBlob);

      // upload the blob
      return this.uploadToFirebase(_imageBlob);
    }).then((_uploadSnapshot: any) => {
      alert('file uploaded successfully  ' + _uploadSnapshot.downloadURL);

      // store reference to storage in database
      return this.saveToDatabaseAssetList(_uploadSnapshot);
github apppresser / ap3 / app / providers / camera / app-camera.ts View on Github external
photoLibrary(appbuddy) {

    if (appbuddy) {
      this.appbuddy = true;
    }

    console.log('appbuddy app-camera.ts', this.appbuddy);

    this.options.sourceType = Camera.PictureSourceType.PHOTOLIBRARY;

    this.doCamera();

  }
github crabcanon / angular2-ionic2-demo / src / providers / native-service.ts View on Github external
return Observable.create((observer) => {
      if (this.platform.is('android') && sourceType === Camera.PictureSourceType.PHOTOLIBRARY) {
        Camera.getPicture(options).then(imagePath => {
          return imagePath; 
        }).catch(error => {
          console.log('Camera GetPicture Error: ', JSON.stringify(error));
          observer.error(error);
        }).then(value => {
          currentName = value.substring(value.lastIndexOf('/') + 1, value.lastIndexOf('?'));
          return FilePath.resolveNativePath(value);
        }).then(filePath => {
          currentPath = filePath.substr(0, filePath.lastIndexOf('/') + 1);
          console.log('CurrentName, CurrentPath: ', currentName, currentPath);
          return this.convertImageAsBase64(currentPath, currentName);
        }).catch(error => {
          console.log('FilePath Resolve Android Native Path Error: ', JSON.stringify(error));
          observer.error(error);
        }).then(imageString => {
github chsakell / ionic2-angular2-firebase / app / pages / profile / profile.ts View on Github external
handler: () => {
            self.openCamera(Camera.PictureSourceType.PHOTOLIBRARY);
          }
        }
github crabcanon / angular2-ionic2-demo / src / pages / camera / camera.ts View on Github external
          handler: () => this.storeImageToSqlite(Camera.PictureSourceType.CAMERA)
        },
github crabcanon / angular2-ionic2-demo / src / pages / camera / camera.ts View on Github external
          handler: () => this.storeImageToSqlite(Camera.PictureSourceType.PHOTOLIBRARY)
        },
github chsakell / ionic2-angular2-firebase / app / pages / profile / profile.ts View on Github external
handler: () => {
            self.openCamera(Camera.PictureSourceType.CAMERA);
          }
        },