EvanPictureService¶
Source | picture |
---|
Picture taking service for HTML 5 / IOS / Android.
takeSnapshot¶
pictureService.takeSnapshot(arguments);
Takes an img. On Desktop the webcam will be used. On mobile IOS / Android internals will be used to access native cameras.
Returns¶
Promise
returns any
: the img data
{
name: 'capture.png',
fileType: 'image/png',
file: arrayBuffer,
blobURI: this._DomSanitizer.bypassSecurityTrustUrl(dataUri)
}
Example¶
const picture = await this.pictureService.takeSnapshot();
getBlobUri¶
pictureService.getBlobUri(dataUrl);
Transform a blob uri from an dataUrl
Parameters¶
dataUrl
-string
: data url that should be transformed
Returns¶
Promise
returns string
: blob uri
Example¶
pictureService.getBlobUri('blob:https://dashboard.test.evan.network/74334fca-0cc3-46d5-9804-2a7161005fe1')
dataURItoBlob¶
pictureService.dataURItoBlob(dataURI);
Transform a data uri in to an blob.
Parameters¶
dataURI
-string
: The options used for calling
Returns¶
Promise
returns any
: transformed blob
Example¶
const buffer = await pictureService.dataURItoBlob('blob:https://dashboard.test.evan.network/74334fca-0cc3-46d5-9804-2a7161005fe1');
blobToDataURI¶
pictureService.blobToDataURI(blob);
Transforms an blob into an data uri.
Parameters¶
blob
-Blob
: The options used for calling
Returns¶
Promise
returns void
: transformed data uri
Example¶
if (dataUri === pictureService.blobToDataURI(pictureService.dataURItoBlob('blob:https://dashboard.test.evan.network/74334fca-0cc3-46d5-9804-2a7161005fe1')) {
console.log('same result')
}
blobToArrayBuffer¶
pictureService.blobToArrayBuffer(blob);
Transforms an blob into an array buffer.
Parameters¶
blob
-any
: blob to transform
Returns¶
Promise
returns any
: transformed array buffer
resizeImage¶
pictureService.resizeImage(dataUri, dimensions);
Takes an dataUri and resizes the img to an maximum px ratio of 1000px:1000px.
Parameters¶
dataUri
-string
: Data Uridimensions
-any
: dimensions to transform the picture to (default max_width: 1000, max_height: 1000)
Returns¶
Promise
returns void
: Returns the resized img as a blob.
Example¶
await pictureService.resizeImage('blob:https://dashboard.test.evan.network/74334fca-0cc3-46d5-9804-2a7161005fe1');