Constructor
new Candidate(source, id, typeopt)
Example
const candidate = new Candidate('/person/123.jpg', '123', 'url')
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
source |
string | The image source for the candidate. |
||
id |
string | The ID for the candidate when the match results are returned this Id will be returned with it's respective results. |
||
type |
string |
<optional> |
base64
|
The type of data in the image source, valid values are 'url', 'base64', and 'dataurl'. If not provided 'base64' is the default. |
Extends
Methods
(async) data()
- Description:
Fetch the image data and base64 encode it
- Source:
- Overrides:
Example
const personPhoto = new ImageSource("/img/photo.jpg")
await personPhoto.data()
console.log(personPhoto.imageData)
(async) toImage()
- Description:
Create an
element, wait for it to load and return it
- Source:
- Overrides:
Example
// Load the image and draw it on a Canvas
const img = await imgSrc.toImage()
const canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d')
canvas.width = img.width
canvas.height = img.height
ctx.drawImage(img, canvas.width, canvas.height, img.width, img.height)