How to use the ionic-native.Camera.getPicture 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.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lockeyo / Graphcool-Ionic-Instagram-Clone / src / pages / camera / camera.ts View on Github external
makePicture(){
      // refresh page here
      Camera.getPicture({
        destinationType: Camera.DestinationType.FILE_URI,
        targetWidth: 1000,
        targetHeight: 1000
      }).then((imageData) => {
        // imageData is a base64 encoded string
        // console.log(imageData);
        // var img64 = "data:image/jpeg;base64," + imageData;
        this.postFile(imageData);
      }, (err) => {
        console.log(err);
      });
    }
}
github apppresser / ap3 / app / providers / camera / app-camera.ts View on Github external
doCamera() {

    Camera.getPicture(this.options).then((imageData) => {
      // imageData is either a base64 encoded string or a file URI
      // If it's base64:
      // let base64Image = "data:image/jpeg;base64," + imageData;
      this.uploadPhoto(imageData);
    }, (err) => {
      alert(err);
    });

  }
github srehanuddin / Teaching-Ionic-MeanStack-SSUET-2015-May-ModuleB / ionic2 / pluginsapp / app / pages / home / home.ts View on Github external
getPicture(){
      alert("Get Picture Called");
      let option = {
          destinationType : Camera["DestinationType"].DATA_URL,
          allowEdit : false,
          targetWidth : 50
      }
      
      Camera.getPicture(option).then((imageData) => {
    // imageData is either a base64 encoded string or a file URI
    // If it's base64:
    //"data:image/jpeg;base64," + 
    let base64Image = imageData;
    this.imageData = base64Image;
        alert(base64Image);
    
    }, (err) => {
    });
      
  }
github maduranga95 / Sobha / src / pages / camera / camera.ts View on Github external
selectPhoto(): void {
    Camera.getPicture({
      sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
      destinationType: Camera.DestinationType.DATA_URL,
      quality: 100,
      encodingType: Camera.EncodingType.PNG,
    }).then(imageData => {
      this.myPhoto = imageData;
      this.uploadPhoto(this.myPhoto);
    }, error => {
      console.log("ERROR -> " + JSON.stringify(error));
    });
  }
github jamzi / instagram-firebase / src / pages / home / home.ts View on Github external
takePhoto() {
    Camera.getPicture({
      destinationType: Camera.DestinationType.DATA_URL,
      targetHeight: 500,
      targetWidth: 500,
      correctOrientation: true
    }).then((imageData) => {
      this.photos.push({ src: "data:image/jpeg;base64," + imageData, likes: 0 });
    }, (err) => {
      console.log(err);
    });
  }
github Urigo / Ionic2-MeteorCLI-WhatsApp / client / imports / pages / messages / messages-attachments.ts View on Github external
takePicture(): void {
    if (!this.platform.is('cordova')) {
      return console.warn('Device must run cordova in order to take pictures');
    }

    Camera.getPicture().then((dataURI) => {
      const blob = this.pictureService.convertDataURIToBlob(dataURI);

      this.viewCtrl.dismiss({
        messageType: MessageType.PICTURE,
        selectedPicture: blob
      });
    });
  }
github thomasgazzoni / ng2-platform / src / camera / camera.ionic.ts View on Github external
.create((observer: Observer) => {

                const cameraOptions: CameraOptions = {
                    destinationType: Camera.DestinationType.FILE_URI,
                    sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
                    encodingType: Camera.EncodingType.JPEG,
                    correctOrientation: true,
                };

                this.setOptions(cameraOptions, options);

                Camera.getPicture(cameraOptions)
                    .then((imageData) => {
                        observer.next(imageData);
                        observer.complete();
                    })
                    .catch(error => {
                        observer.error(this.getErrorMessage(error));
                        observer.complete();
                    });
            });
    }
github chsakell / ionic2-angular2-firebase / app / pages / profile / profile.ts View on Github external
openCamera(pictureSourceType: any) {
    var self = this;

    let options: CameraOptions = {
      quality: 95,
      destinationType: Camera.DestinationType.DATA_URL,
      sourceType: pictureSourceType,
      encodingType: Camera.EncodingType.PNG,
      targetWidth: 400,
      targetHeight: 400,
      saveToPhotoAlbum: true,
      correctOrientation: true
    };

    Camera.getPicture(options).then(imageData => {
      const b64toBlob = (b64Data, contentType = '', sliceSize = 512) => {
        const byteCharacters = atob(b64Data);
        const byteArrays = [];

        for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
          const slice = byteCharacters.slice(offset, offset + sliceSize);

          const byteNumbers = new Array(slice.length);
          for (let i = 0; i < slice.length; i++) {
            byteNumbers[i] = slice.charCodeAt(i);
          }

          const byteArray = new Uint8Array(byteNumbers);

          byteArrays.push(byteArray);
        }
github zyra / ionic-native-playground / app / pages / main / main.ts View on Github external
camera () : void {

        let options = {
            targetWidth: 500,
            destinationType: 0
        };

        Camera.getPicture(options)
            .then(
                (photo : any) =&gt; this.updateOutput('<img alt="" src="data:image/jpeg;base64,'+photo+'">'),
                (error : string) =&gt; this.updateOutput(error, true)
            );

    }