@capacitor-community/camera-preview
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -7,5 +7,5 @@ export declare type CameraPosition = 'rear' | 'front'; | ||
className?: string; | ||
/** The preview width in pixels, default window.screen.width (applicable to the android and ios platforms only) */ | ||
/** The preview width in pixels, default window.screen.width */ | ||
width?: number; | ||
/** The preview height in pixels, default window.screen.height (applicable to the android and ios platforms only) */ | ||
/** The preview height in pixels, default window.screen.height */ | ||
height?: number; | ||
@@ -24,3 +24,3 @@ /** The x origin, default 0 (applicable to the android and ios platforms only) */ | ||
position?: CameraPosition | string; | ||
/** Defaults to false - Capture images to a file and return back the file path instead of returning base64 encoded data */ | ||
/** Defaults to false - Capture images to a file and return the file path instead of returning base64 encoded data */ | ||
storeToFile?: boolean; | ||
@@ -35,5 +35,5 @@ /** Defaults to false - Android Only - Disable automatic rotation of the image, and let the browser deal with it (keep reading on how to achieve it) */ | ||
lockAndroidOrientation?: boolean; | ||
/** Defaults to false - Android and Web only. Set if camea preview can change opacity. */ | ||
/** Defaults to false - Android and Web only. Set if camera preview can change opacity. */ | ||
enableOpacity?: boolean; | ||
/** Defaults to false - Android only. Set if camea preview will support pinch to zoom. */ | ||
/** Defaults to false - Android only. Set if camera preview will support pinch to zoom. */ | ||
enableZoom?: boolean; | ||
@@ -46,3 +46,5 @@ } | ||
width?: number; | ||
/** The picture quality, 0 - 100, default 85 */ | ||
/** The picture quality, 0 - 100, default 85 on `iOS/Android`. | ||
* | ||
* If left undefined, the `web` implementation will export a PNG, otherwise a JPEG will be generated */ | ||
quality?: number; | ||
@@ -73,5 +75,5 @@ } | ||
flashMode: CameraPreviewFlashMode | string; | ||
}): void; | ||
flip(): void; | ||
}): Promise<void>; | ||
flip(): Promise<void>; | ||
setOpacity(options: CameraOpacityOptions): Promise<{}>; | ||
} |
@@ -12,3 +12,3 @@ import { WebPlugin } from '@capacitor/core'; | ||
stop(): Promise<any>; | ||
capture(_options: CameraPreviewPictureOptions): Promise<any>; | ||
capture(options: CameraPreviewPictureOptions): Promise<any>; | ||
captureSample(_options: CameraSampleOptions): Promise<any>; | ||
@@ -15,0 +15,0 @@ getSupportedFlashModes(): Promise<{ |
@@ -14,3 +14,3 @@ import { WebPlugin } from '@capacitor/core'; | ||
audio: !options.disableAudio, | ||
video: true, | ||
video: true | ||
}) | ||
@@ -47,6 +47,9 @@ .then((stream) => { | ||
const constraints = { | ||
video: true, | ||
video: { | ||
width: { ideal: options.width }, | ||
height: { ideal: options.height } | ||
} | ||
}; | ||
if (options.position === 'rear') { | ||
constraints.video = { facingMode: 'environment' }; | ||
constraints.video.facingMode = 'environment'; | ||
this.isBackCamera = true; | ||
@@ -85,3 +88,3 @@ } | ||
} | ||
async capture(_options) { | ||
async capture(options) { | ||
return new Promise((resolve, _) => { | ||
@@ -100,4 +103,11 @@ const video = document.getElementById('video'); | ||
context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight); | ||
let base64EncodedImage; | ||
if (options.quality != undefined) { | ||
base64EncodedImage = canvas.toDataURL('image/jpeg', options.quality / 100.0).replace('data:image/jpeg;base64,', ''); | ||
} | ||
else { | ||
base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', ''); | ||
} | ||
resolve({ | ||
value: canvas.toDataURL('image/png').replace('data:image/png;base64,', ''), | ||
value: base64EncodedImage, | ||
}); | ||
@@ -104,0 +114,0 @@ }); |
{ | ||
"name": "@capacitor-community/camera-preview", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "Camera preview", | ||
@@ -5,0 +5,0 @@ "main": "dist/esm/index.js", |
@@ -62,3 +62,12 @@ <p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p> | ||
then in html add | ||
<div id="cameraPreview"></div> | ||
and | ||
ngOnInit() { const { CameraPreview } = Plugins; CameraPreview.start({ parent: "cameraPreview"}); } | ||
it will work | ||
# Methods | ||
@@ -65,0 +74,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
332365
243
441