Skip to main content

ImageRef API in Capacitor Document Scanner SDK

ImageRef is a lightweight image reference type used throughout the Scanbot SDK to represent image data in a unified and effective manner. Additionally, it acts as a universal interface for images that any component of the SDK captures, processes, or returns. It enables memory efficient Image processing across the SDK and also makes it cross accessible across the SDKs on supported platforms.

ImageRef from Encoded Buffer

ImageRef can be created from an encoded image buffer, which is a base64 string containing the image data in a specific format (e.g., JPEG, PNG). This allows you to work with images that are already in memory without needing to save them to disk first.

Creating ImageRef from Encoded Buffer
loading...

ImageRef from File URI

ImageRef can also be created from a file URI, which is a string representing the location of an image file on the device's storage.

Creating ImageRef from File URI
loading...

ImageRef from Serialized Ref

ImageRef can be created from a serialized reference, which is an object that contains an identifier string that can be used to retrieve the ImageRef later.

Creating ImageRef from Serialized Ref
loading...

Utilizing ImageRef

Once you have an ImageRef, you can use it with various SDK components that accept ImageRef as input. ImageRef can also be used to save images to disk or convert them to encoded buffers for further processing.

Using ImageRefs
loading...

If you need to use an ImageRef outside the current autorelease block, serialize it and later deserialize it within a new autorelease block. This ensures proper memory management and release when the ImageRef is no longer needed.

Buffer Serialization

The ImageRef can be serialized to a buffer and deserialized back to an ImageRef when needed.

Serializing and Deserializing ImageRef
loading...

Reference Serialization

An ImageRef can be serialized into an object with a uniqueId property and later deserialized to reconstruct the ImageRef.

Serializing and Deserializing ImageRef
loading...

Want to scan longer than one minute?

Generate a free trial license to test the Scanbot SDK thoroughly.

Get free trial license