# TensorFactory | ONNX Runtime JavaScript API
Documentation for ONNX Runtime JavaScript API

# Interface TensorFactory

#### Hierarchy

- TensorFactory

- Defined in tensor.ts:314

#####
Index

### Methods

fromImage

## Methods

### fromImage

- fromImage(imageData: ImageData, options?: TensorFromImageOptions ): Promise< Tensor >

- create a tensor from image object - HTMLImageElement, ImageData, ImageBitmap, URL

  ### Returns

  A promise that resolves to a tensor object

  #### Parameters

  - ##### imageData: ImageData

    {ImageData} - composed of: Uint8ClampedArray, width. height - uses known pixel format RGBA

  - ##### `Optional` options: TensorFromImageOptions

    Optional - Interface describing input image & output tensor - Input Defaults: RGBA, 3 channels, 0-255, NHWC - Output Defaults: same as input parameters

  #### Returns Promise< Tensor >

  - Defined in tensor.ts:323
- fromImage(imageElement: HTMLImageElement, options?: TensorFromImageOptions ): Promise< Tensor >

- create a tensor from image object - HTMLImageElement, ImageData, ImageBitmap, URL

  ### Returns

  A promise that resolves to a tensor object

  #### Parameters

  - ##### imageElement: HTMLImageElement

    {HTMLImageElement} - since the data is stored as ImageData no need for format parameter

  - ##### `Optional` options: TensorFromImageOptions

    Optional - Interface describing input image & output tensor - Input Defaults: RGBA, 3 channels, 0-255, NHWC - Output Defaults: same as input parameters

  #### Returns Promise< Tensor >

  - Defined in tensor.ts:333
- fromImage(url: string, options?: TensorFromImageOptions ): Promise< Tensor >

- create a tensor from image object - HTMLImageElement, ImageData, ImageBitmap, URL

  ### Returns

  A promise that resolves to a tensor object

  #### Parameters

  - ##### url: string

    {string} - Assuming the string is a URL to an image

  - ##### `Optional` options: TensorFromImageOptions

    Optional - Interface describing input image & output tensor - Input Defaults: RGBA, 3 channels, 0-255, NHWC - Output Defaults: same as input parameters

  #### Returns Promise< Tensor >

  - Defined in tensor.ts:343
- fromImage(bitmap: ImageBitmap, options: TensorFromImageOptions ): Promise< Tensor >

- create a tensor from image object - HTMLImageElement, ImageData, ImageBitmap, URL

  ### Returns

  A promise that resolves to a tensor object

  #### Parameters

  - ##### bitmap: ImageBitmap

  - ##### options: TensorFromImageOptions

    NOT Optional - Interface describing input image & output tensor - Output Defaults: same as input parameters

  #### Returns Promise< Tensor >

  - Defined in tensor.ts:353

Generated using TypeDoc