Extract document images
BlinkID can return images alongside extraction results. This is useful when you need to pass the captured document images to a downstream service—such as the BlinkID Verify API—or store them for audit purposes.
Types of images
BlinkID can return two distinct types of images:
- Input images (raw camera frames): the original, unprocessed frames captured by the camera, including the background around the document.
- Document images (cropped): perspective-corrected images tightly framed on the document itself.
If you are passing images to Verify, use raw input images.
Enable image return
- Web (TS)
- Android (Kotlin)
- iOS (Swift)
Set inputImageReturnEnabled: true inside documentCaptureModule:
const settings: ScanningSettings = {
documentCaptureModule: {
inputImageReturnEnabled: true,
},
};
To also receive cropped document or face images, set the corresponding flags in documentCaptureModule:
const settings: ScanningSettings = {
documentCaptureModule: {
inputImageReturnEnabled: true,
documentImageReturnEnabled: true,
faceImageExtractionEnabled: true,
},
};
Set inputImageReturnEnabled = true inside DocumentCaptureModuleSettings:
val sessionSettings = BlinkIdSessionSettings(
scanningSettings = ScanningSettings(
documentCaptureModule = DocumentCaptureModuleSettings(
inputImageReturnEnabled = true
)
)
)
Pass sessionSettings when launching the scanning screen:
BlinkIdCameraScanningScreen(
blinkIdSdk = sdk,
sessionSettings = sessionSettings,
onScanningSuccess = { result -> },
onScanningCanceled = { }
)
Set inputImageReturnEnabled: true inside DocumentCaptureModuleSettings:
let analyzer = try await BlinkIDAnalyzer(
sdk: sdkInstance,
blinkIdSessionSettings: BlinkIDSessionSettings(
scanningSettings: ScanningSettings(
documentCaptureModule: DocumentCaptureModuleSettings(
inputImageReturnEnabled: true
)
)
),
eventStream: BlinkIDEventStream()
)
Access images on the result
- Web (TS)
- Android (Kotlin)
- iOS (Swift)
The result contains inputImageFront, inputImageBack, and inputImageBarcode fields with the raw ImageData frames.
Encode to PNG before sending to an API:
const canvas = document.createElement("canvas");
canvas.width = result.inputImageFront.width;
canvas.height = result.inputImageFront.height;
canvas.getContext("2d")!.putImageData(result.inputImageFront, 0, 0);
const base64 = canvas.toDataURL("image/png").split(",")[1];
Call inputImage(scanningSide) on the result to get the raw frame for each side:
val frontBitmap = scanningResult.inputImage(ScanningSide.First)?.bitmap
val backBitmap = scanningResult.inputImage(ScanningSide.Second)?.bitmap
fun encodeToPng(bitmap: Bitmap): String {
val stream = ByteArrayOutputStream()
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream)
return Base64.encodeToString(stream.toByteArray(), Base64.DEFAULT)
}
Call getInputImage(scanningSide:) on the result to get the raw frame for each side:
if let front = scanningResult.getInputImage(scanningSide: .first),
let pngData = front.uiImage?.pngData() {
let base64 = pngData.base64EncodedString()
// pass base64 to your API
}
if let back = scanningResult.getInputImage(scanningSide: .second),
let pngData = back.uiImage?.pngData() {
let base64 = pngData.base64EncodedString()
}
Use lossless compression
Do not use lossy compression (such as JPEG) on images you intend to pass to a verification backend. Lossy compression degrades image quality in ways that can affect analysis. Encode to PNG instead, as shown in the examples above.
Do not post-process images
Pass the images as-is from the SDK result. Do not crop, resize, rotate, or otherwise modify them after capture. Post-processing can break assumptions that downstream services make about image integrity.