onnxruntime/js/common
Artyom Stepanishchev ba23e5b234
[JS/Common] Fix malformed result of Tensor.fromImage(ImageBitmap) (#16919)
### Description

Set `canvas` dimensions to the `ImageBitmap` dimensions, thus fixing a
malformed Tensor creation.

### Motivation and Context

According to the [HTMLCanvasElement.drawImage()
spec](https://html.spec.whatwg.org/multipage/canvas.html#drawing-images):
> When the destination rectangle is outside the destination image (the
output bitmap), the pixels that land outside the output bitmap are
discarded, as if the destination was an infinite canvas whose rendering
was clipped to the dimensions of the output bitmap.

meaning that `ImageBitmap` pixels exceeding the canvas dimensions will
be discarded. Since no canvas dimensions are set for
`Tensor.fromImage(ImageBitmap)` if-case, the default 300x150px canvas
dimensions are used leading to the creation of malformed Tensors where
all the exceeding pixels are discarded and equal to `0, 0, 0, 0` during
the subsequent `pixels2DContext.getImageData()` call.
2023-07-31 18:18:06 -07:00
..
lib [JS/Common] Fix malformed result of Tensor.fromImage(ImageBitmap) (#16919) 2023-07-31 18:18:06 -07:00
test [js/common] add unit tests for onnxruntime-common (#16812) 2023-07-25 14:37:41 -07:00
.gitignore [js/common] add unit tests for onnxruntime-common (#16812) 2023-07-25 14:37:41 -07:00
.npmignore [js/common] allow import onnxruntime-common as ESM and CJS (#15772) 2023-06-12 12:05:11 -07:00
build.js [js/common] allow import onnxruntime-common as ESM and CJS (#15772) 2023-06-12 12:05:11 -07:00
package-lock.json Update VERSION_NUMBER (#15773) 2023-05-03 15:07:34 -07:00
package.json [js] enable formatter for more file types (#16888) 2023-07-28 15:46:58 -07:00
README.md Replace 'master' branch ref to 'main' in the code (#12547) 2022-08-22 10:48:12 -07:00
tsconfig.json [js] enable formatter for more file types (#16888) 2023-07-28 15:46:58 -07:00
typedoc.json [js] enable formatter for more file types (#16888) 2023-07-28 15:46:58 -07:00
webpack.config.js [js/common] allow import onnxruntime-common as ESM and CJS (#15772) 2023-06-12 12:05:11 -07:00

ONNX Runtime JavaScript API

ONNX Runtime JavaScript API is a unified API for all JavaScript usages. It's dependency of the following NPM packages:

  • onnxruntime-node
  • onnxruntime-web
  • onnxruntime-react-native

This package (onnxruntime-common) is not designed for using directly. Please consider to install one of the NPM packages above according to target platform.

License

License information can be found here.