How to use the ionic-native.Camera.DestinationType 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 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) => {
    alert('file uploaded successfully  ' + _uploadSnapshot.downloadURL);

    // store reference to storage in database
github thomasgazzoni / ng2-platform / src / camera / camera.ionic.ts View on Github external
.create((observer: Observer) => {

                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 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 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
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 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 crabcanon / angular2-ionic2-demo / src / providers / native-service.ts View on Github external
setOptions(srcType: number) {
    let options = {
      quality: 50,
      targetWidth: 300,
      targetHeight: 300,
      destinationType: Camera.DestinationType.FILE_URI,
      sourceType: srcType,
      encondingType: Camera.EncodingType.JPEG,
      mediaType: Camera.MediaType.PICTURE,
      allowEdit: true,
      correctOrientation: true
    }
    return options;
  }
github apppresser / ap3 / app / providers / camera / app-camera.ts View on Github external
import {Injectable} from '@angular/core';
import {Camera, Transfer, Device} from 'ionic-native';

/*
  Generated class for the Menus provider.

  See https://angular.io/docs/ts/latest/guide/dependency-injection.html
  for more info on providers and Angular 2 DI.
*/
@Injectable()
export class AppCamera {

  options: any = {
    quality: 30,
    destinationType: Camera.DestinationType.FILE_URI,
    correctOrientation: true,
    targetWidth: 1204,
    targetHeight: 1204
  };

  iframedoc: any;
  appbuddy: boolean = false;

  constructor() { }

  takePicture(appbuddy) {

    if(appbuddy) {
      this.appbuddy = true;
    }
github Lacka90 / ionic-photo-maps / src / pages / photo / photo.ts View on Github external
takePicture() {
    if (this.base64Image === this.PLACEHOLDER) {
      Camera.getPicture({
        correctOrientation: true,
        targetWidth: 720,
        destinationType: Camera.DestinationType.FILE_URI,
      }).then((fileData) => {
        this.locationLoading = true;
        return this.makeBlobFromFile(fileData);
      }).then((imageData) => {
        return this.rotateImage(imageData);
      }).then((rotatedData: Blob) => {
        this.image = rotatedData;
        const urlCreator = window.URL || (window as any).webkitURL;
        this.base64Image = urlCreator.createObjectURL(rotatedData);
        this.getGeoCoords().then(coords => this.coords = coords);
      });
    } else {
      this.resetCoords();
      this.base64Image = this.PLACEHOLDER;
    }
  }
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);