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.
Capture images for Verify with a use case
Added in BlinkID Web v8003.0.0, and in BlinkID Android and iOS v8002.0.0. Earlier v8xxx versions don't have use cases; follow Enable image return instead.
If you are passing images to Verify, use the Verify capture use case. It enables input image return, face image extraction, and barcode image return, and reads the VIZ from a single best frame instead of combining multiple frames.
- Web (TS)
- Android (Kotlin)
- iOS (Swift)
import { createBlinkId } from "@microblink/blinkid";
const blinkId = await createBlinkId({
licenseKey: "your-license-key",
presetScanningSettingsBuilder: (presetBuilder) =>
presetBuilder.buildVerifyCaptureSettings(),
});
BlinkIdCameraScanningScreen(
blinkIdSdk = sdk,
sessionSettings = BlinkIdSessionSettings.verifyCapture(),
onScanningSuccess = { result -> },
onScanningCanceled = { }
)
let analyzer = try await BlinkIDAnalyzer(
sdk: sdkInstance,
blinkIdSessionSettings: BlinkIDSessionSettings.verifyCapture(),
eventStream: BlinkIDEventStream()
)
Then continue with Access images on the result.
Enable image return
Applies to versions earlier than BlinkID Web v8003.0.0, and BlinkID Android and iOS v8002.0.0. If you have a newer version and are passing images to Verify, you can also use the Verify capture use case.
- Web (TS)
- Android (Kotlin)
- iOS (Swift)
- Flutter (Dart)
- React Native (TS)
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()
)
Set inputImageReturnEnabled: true inside DocumentCaptureModuleSettings:
// Modules you leave out are disabled, so list every module you need.
final sessionSettings = BlinkIdSessionSettings(
scanningSettings: BlinkIdScanningSettings(
documentCaptureModule: DocumentCaptureModuleSettings(
inputImageReturnEnabled: true,
),
mrzModule: MrzModuleSettings(),
barcodeModule: BarcodeModuleSettings(),
vizModule: VizModuleSettings(),
),
);
To also receive cropped document or face images, set the corresponding flags in DocumentCaptureModuleSettings:
final sessionSettings = BlinkIdSessionSettings(
scanningSettings: BlinkIdScanningSettings(
documentCaptureModule: DocumentCaptureModuleSettings(
inputImageReturnEnabled: true,
documentImageReturnEnabled: true,
faceImageExtractionEnabled: true,
),
mrzModule: MrzModuleSettings(),
barcodeModule: BarcodeModuleSettings(),
vizModule: VizModuleSettings(),
),
);
Set inputImageReturnEnabled: true inside documentCaptureModule:
// Modules you leave out are disabled, so list every module you need.
const sessionSettings: BlinkIdSessionSettings = {
scanningSettings: {
documentCaptureModule: {
inputImageReturnEnabled: true,
},
mrzModule: {},
barcodeModule: {},
vizModule: {},
},
};
To also receive cropped document or face images, set the corresponding flags in documentCaptureModule:
const sessionSettings: BlinkIdSessionSettings = {
scanningSettings: {
documentCaptureModule: {
inputImageReturnEnabled: true,
documentImageReturnEnabled: true,
faceImageExtractionEnabled: true,
},
mrzModule: {},
barcodeModule: {},
vizModule: {},
},
};
Access images on the result
- Web (TS)
- Android (Kotlin)
- iOS (Swift)
- Flutter (Dart)
- React Native (TS)
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()
}
The result exposes firstInputImage and secondInputImage as Base64-encoded strings, one per scanned side:
if (result != null) {
final String? frontBase64 = result.firstInputImage;
final String? backBase64 = result.secondInputImage;
// pass the Base64 strings to your API
}
The result exposes firstInputImage and secondInputImage as Base64-encoded strings, one per scanned side:
const frontBase64 = result.firstInputImage;
const backBase64 = result.secondInputImage;
// pass the Base64 strings to your API
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.