Skip to content

Latest commit

 

History

History
1389 lines (984 loc) · 26.3 KB

File metadata and controls

1389 lines (984 loc) · 26.3 KB
layout default-layout
needAutoGenerateSidebar true
title Dynamic Web TWAIN SDK API Reference - Edit APIs
keywords Dynamic Web TWAIN, Documentation, API Reference, Edit APIs
breadcrumbText Edit
description Dynamic Web TWAIN SDK Documentation API Reference Edit APIs Page

{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.

Methods

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

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v15.3+ v15.3+ v15.3+ v15.3+

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

Invert()

Invert the color 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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v15.3+ v15.3+ v15.3+ v15.3+

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
---

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

CopyToClipboard()

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

Syntax

CopyToClipboard(index: number): boolean;

Parameters

index: Specify the image.

Availability

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

CutToClipboard()

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

Syntax

CutToClipboard(index: number): boolean;

Parameters

index: Specify the image.

Availability

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

Usage notes

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


BackgroundFillColor

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

Syntax

BackgroundFillColor: number;

Availability

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

Usage notes

By default the color 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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.2+ v17.2+ v17.2+ v17.2+

ChangeContrastAsync()

Change the image contrast.

Syntax

ChangeContrastAsync(
    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

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.2+ v17.2+ v17.2+ v17.2+