Dev Center
Table of contents

Thanks for Downloading Dynamic Web TWAIN 30-Day Trial!

Your download will start shortly. If your download does not begin, click here to retry.

{WebTwainObject} Edit

The properties and methods on this page live in the namespace {WebTwainObject}. {WebTwainObject} denotes the WebTwain instance. Learn about how to create a web twain object.

All APIs on this page support Android Service from version 18.2.

Methods

       
Crop() CropToClipboard() CutFrameToClipboard() CutToClipboard()
CopyToClipboard() Erase() Flip() Mirror()
Rotate() RotateEx() RotateLeft() RotateRight()
ChangeBitDepth() SetDPI() ConvertToBW() ConvertToGrayScale()
ChangeImageSize() Invert() SetImageWidth() ChangeBrightnessAsync()
ChangeContrastAsnyc()      

Properties

 
BackgroundFillColor

ChangeBitDepth()

Change the bit depth of the specified image.

Syntax

ChangeBitDepth(
    index: number,
    bitDepth: number,
    highQuality: boolean,
): boolean;

Parameters

index: Specify the index of the image to be changed. The index is 0-based.

bitDepth: Specify the target bit depth.

highQuality: Whether to keep high quality. When it’s true, it takes more time.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v10.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

Usage notes

The allowed bit depths are 1, 4, 8, 24.


ChangeImageSize()

Change the size of the specified image.

Syntax

ChangeImageSize(
    index: number,
    width: number,
    height: number,
    method: Dynamsoft.DWT.EnumDWT_InterpolationMethod | number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
ChangeImageSize(
    index: number,
    width: number,
    height: number,
    method: Dynamsoft.DWT.EnumDWT_InterpolationMethod | number,
    successCallback: () => void,
    failureCallback: (
        errorCode: number,
        errorString: string
    ) => void
): void;

Parameters index: Specify the index of the image to be changed. The index is 0-based.

width: Specify the new width.

height: Specify the new height.

method: Specify the algorithm for the change. Please refer to EnumDWT_InterpolationMethod.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

SetDPI()

Change the DPI (dots per inch) of the specified image.

Syntax

SetDPI(
    index: number,
    xResolution: number,
    yResolution: number,
    resample: boolean,
    method: Dynamsoft.DWT.EnumDWT_InterpolationMethod | number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
SetDPI(
    index: number,
    xResolution: number,
    yResolution: number,
    resample: boolean,
    method: Dynamsoft.DWT.EnumDWT_InterpolationMethod | number,
    successCallback: () => void,
    failureCallback: (
        errorCode: number,
        errorString: string
    ) => void
): void;

Parameters

index: Specify the index of the image to be changed. The index is 0-based.

xResolution: Specify the horizontal DPI.

yResolution: Specify the vertical DPI.

resample: Whether to resample the image. When it is true, the image size will change.

method: Specify the algorithm for the change. Please refer to EnumDWT_InterpolationMethod.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v8.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

ConvertToBW()

Convert the specified image to black & white.

Syntax

ConvertToBW(
    index: number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
ConvertToBW(
    index: number,
    successCallback: () => void,
    failureCallback: (
        errorCode: number,
        errorString: string
    ) => void
): void;

Parameters

index: Specify the index of the image to be converted. The index is 0-based.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
not supported v15.3+ v15.3+ v15.3+ v15.3+ v18.2+

ConvertToGrayScale()

Convert the specified image to grayscale.

Syntax

ConvertToGrayScale(
    index: number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
ConvertToGrayScale(
    index: number,
    successCallback: () => void,
    failureCallback: (
        errorCode: number,
        errorString: string
    ) => void
): void;

Parameters

index: Specify the index of the image to be converted. The index is 0-based.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v10.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

Invert()

Invert the colour of the pixels on the specified image.

Syntax

Invert(
    index: number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
Invert(
    index: number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

index: Specify the image.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
not supported v15.3+ v15.3+ v15.3+ v15.3+ v18.2+

SetImageWidth()

Change the width of the specified image by adding a margin or removing part of the image.

Syntax

SetImageWidth(
    index: number,
    width: number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
SetImageWidth(
    index: number,
    width: number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

index: Specify the image.

width: Specify the new width.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v10.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

Flip()

Flip the specified image.

Syntax

Flip(
    index: number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
Flip(
    index: number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

index: Specify the image.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v6.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

Mirror()

Mirror the specified image.

Syntax

Mirror(
    index: number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
Mirror(
    index: number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

index: Specify the image.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

RotateLeft()

Rotate the specified image 90 degrees counterclockwise.

Syntax

RotateLeft(
    index: number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
RotateLeft(
    index: number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

index: Specify the image.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

RotateRight()

Rotate the specified image 90 degrees clockwise.

Syntax

RotateRight(
    index: number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
RotateRight(
    index: number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

index: Specify the image.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

Rotate()

Rotate the specified image by the specified angle.

Syntax

Rotate(
    index: number,
    angle: number,
    keepSize: boolean
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
Rotate(
    index: number,
    angle: number,
    keepSize: boolean,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

index: Specify the image.

angle: Specify the angle.

keepSize: Whether to keep the original size.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v6.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

RotateEx()

Rotate the specified image by the specified angle.

Syntax

RotateEx(
    index: number,
    angle: number,
    keepSize: boolean,
    method: Dynamsoft.DWT.EnumDWT_InterpolationMethod | number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
RotateEx(
    index: number,
    angle: number,
    keepSize: boolean,
    method: Dynamsoft.DWT.EnumDWT_InterpolationMethod | number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

index: Specify the image.

angle: Specify the angle.

keepSize: Whether to keep the original size.

method: Specify the algorithm for the change. Please refer to Dynamsoft.DWT.EnumDWT_InterpolationMethod.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v7.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

Crop()

Crop the specified image using the specified coordinates.

Syntax

Crop(
    index: number,
    left: number,
    top: number,
    right: number,
    bottom: number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
Crop(
    index: number,
    left: number,
    top: number,
    right: number,
    bottom: number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

index: Specify the image.

left: Specify the rectangle (leftmost coordinate).

top: Specify the rectangle (topmost coordinate).

right: Specify the rectangle (rightmost coordinate).

bottom: Specify the rectangle (bottommost coordinate).

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v6.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

Erase()

Erase a rectangular area from the specified image.

Syntax

Erase(
    index: number,
    left: number,
    top: number,
    right: number,
    bottom: number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
Erase(
    index: number,
    left: number,
    top: number,
    right: number,
    bottom: number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

index: Specify the image.

left: Specify the rectangle (leftmost coordinate).

top: Specify the rectangle (topmost coordinate).

right: Specify the rectangle (rightmost coordinate).

bottom: Specify the rectangle (bottommost coordinate).

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v6.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

CopyToClipboard()

Copy the specified image to the clipboard of the operating system.

Syntax

CopyToClipboard(index: number): boolean;

Parameters

index: Specify the image.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

CutToClipboard()

Cut the specified image to the clipboard of the operating system.

Syntax

CutToClipboard(index: number): boolean;

Parameters

index: Specify the image.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

CropToClipboard()

Crop a rectangular area from the specified image to the clipboard of the operating system.

Syntax

CropToClipboard(
    index: number,
    left: number,
    top: number,
    right: number,
    bottom: number
): boolean;

Parameters

index: Specify the image.

left: Specify the rectangle (leftmost coordinate).

top: Specify the rectangle (topmost coordinate).

right: Specify the rectangle (rightmost coordinate).

bottom: Specify the rectangle (bottommost coordinate).

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

CutFrameToClipboard()

Cut a rectangular area from the specified image to the clipboard of the operating system.

Syntax

CutFrameToClipboard(
    index: number,
    left: number,
    top: number,
    right: number,
    bottom: number
): boolean;

Parameters

index: Specify the image.

left: Specify the rectangle (leftmost coordinate).

top: Specify the rectangle (topmost coordinate).

right: Specify the rectangle (rightmost coordinate).

bottom: Specify the rectangle (bottommost coordinate).

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v6.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

Usage notes

The empty area resulted from the crop/erase/cut will be filled with the colour set with BackgroundFillColor.


BackgroundFillColor

Return or set the fill colour for the empty area on an image that has been cut/cropped/erased.

Syntax

BackgroundFillColor: number;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v6.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

Usage notes

By default the colour is white (0xffffff). The byte-ordering of the 24-bit RGB value is RRGGBB. RR represents red, GG represents green and BB represents blue.


ChangeBrightnessAsync()

Change the image brightness.

Syntax

ChangeBrightnessAsync(
    index: number, 
    value: number
): Promise<boolean>;

Parameters

index: Specify the index of image in buffer.

value: Specify the brightness. Allowed values [-1000~1000]. Negative value means decrease the brightness.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
not supported v17.2+ v17.2+ v17.2+ v17.2+ v18.2+

ChangeContrastAsnyc()

Change the image contrast.

Syntax

ChangeContrastAsnyc(
    index: number, 
    value: number
): Promise<boolean>;

Parameters

index: Specify the index of image in buffer.

value: Specify the contrast. Allowed values [-1000~1000]. Negative value means decrease the contrast.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
not supported v17.2+ v17.2+ v17.2+ v17.2+ v18.2+

Is this page helpful?

YesYes NoNo

In this article:

latest version

    • Latest Version (18.4)
    • Version 18.3
    • Version 18.1
    • Version 18.0
    • Version 17.3
    • Version 17.2.1
    • Version 17.1.1
    • Version 17.0
    • Version 16.2
    • Version 16.1.1
    Change +