Camera

Contents

Take a photo or capture video.

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

Ionic 拍照Camera插件的安装(Installation)

ionic cordova plugin add cordova-plugin-camera npm install @ionic-native/camera

Ionic 拍照Camera插件支持的平台(Supported Platforms)

  • Android
  • Browser
  • iOS
  • Windows

Ionic 拍照Camera插件的用法(Usage)

import { Camera, CameraOptions } from '@ionic-native/camera';

constructor(private camera: Camera) { }

...


const options: CameraOptions = {
  quality: 100,
  destinationType: this.camera.DestinationType.FILE_URI,
  encodingType: this.camera.EncodingType.JPEG,
  mediaType: this.camera.MediaType.PICTURE
}

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