Working with Images

Each document will contain one or more images. Each image represents a page or side of the document, for example, the front and back of a driving licence.

  • Document.Images provides a list of all the images for the given document.

Image Metadata

The following example shows how to download the data for a document and access the image metadata:

Request

POST {{server}}/VPE/dataAccess/retrieveDocumentContainer/
Content-Type: application/json

{
    "DeviceId": "device-id",
    "SessionId": "...",
    "ContainerId": "..."
}

Response

{
    "Success": true,
    "Message": "Operation executed successfully.",
    "AccessDenied": false,
    "SessionExpired": false,
    "Container":
    {
        "Documents": [
        {
            "Images": [{
                "CreatedAt": {...},
                "CropArea": {
                    BottomLeft: {x: 0, y: 0},
                    BottomRight: {x: 0, y: 0},
                    TopLeft: {x: 0, y: 0},
                    TopRight: {x: 0, y: 0}
                },
                "DocumentId": "...",
                "FileType": 1,
                "Id": "...",
                "ImageSourceId": null,
                "ImageType": 2,
                "Rotation": 0
            }],
       }]
    }
}

Use the Document.Images property to access image metadata.

Image Types

The TrustID Javascript API distinguishes different types of images. The main image types are as follows:

The metadata for an image of a specific image type can be obtained using the helper method as part of the document object as shown here:

var api = new TVS.Api();
api.login('username', 'password').then(function() {
    // retrieve document container for the given containerId(guid)...
    return api.retrieveDocumentContainer(containerId);
}).then(function(application) {
    // examine first document in application
    var doc = application.Documents[0];

    var img = doc.getImageByType(Image.IMAGE_TYPE_DOCUMENT);
    if (img) {
       console.log('full document image (white light):', img.getImageTypeDisplay(), img.Id);
    } else {
       console.log('document does not have metadata of a full white light document image');
    }
});

Note

The actual binary image data can be retrieved from the TrustID Cloud separately - for example, to present an image to an operator. See Retrieving Image Data for more information.