Ionic3 uses cameras and ionic3 uses cameras.
Cordova-plugin-camera plugin
Installation:
$ ionic cordova plugin add cordova-plugin-camera$ npm install --save @ionic-native/camera
Use the providers reference plug-in of app. module. ts
Import {Camera, CameraOptions} from '@ ionic-native/camera'; constructor (private camera: Camera) {}// set the option const options: CameraOptions = {quality: 100, sourceType: this. camera. pictureSourceType. CAMERA, destinationType: this. camera. destinationType. DATA_URL, encodingType: this. camera. encodingType. JPEG, mediaType: this. camera. mediaType. PICTURE} // obtain the image this. camera. getPicture (options ). then (imageData) ==>{// get succeeded let base64Image = 'data: image/jpeg; base64, '+ imageData ;}, (err) ==>{ console. log ('image retrieval failed ');});
CameraOptions parameter description:
| CameraOptions |
Parameter |
| Quality |
The higher the image quality, the better. |
| SourceType |
Image Source |
| DestinationType |
Image path |
| EncodingType |
Image Type |
| MediaType |
Media type. This plug-in can also select videos. |
SourceType
-PHOTOLIBRARY: used to retrieve a single image from the album.
-Take a photo of CAMERA,
-SAVEDPHOTOALBUM: Save the image