onnxruntime/js/common/lib
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
..
backend-impl.ts [js/common] allow import onnxruntime-common as ESM and CJS (#15772) 2023-06-12 12:05:11 -07:00
backend.ts [js/common] allow import onnxruntime-common as ESM and CJS (#15772) 2023-06-12 12:05:11 -07:00
env-impl.ts [js/common] allow import onnxruntime-common as ESM and CJS (#15772) 2023-06-12 12:05:11 -07:00
env.ts [js/common] allow import onnxruntime-common as ESM and CJS (#15772) 2023-06-12 12:05:11 -07:00
index.ts [js/common] allow import onnxruntime-common as ESM and CJS (#15772) 2023-06-12 12:05:11 -07:00
inference-session-impl.ts [js/common] allow import onnxruntime-common as ESM and CJS (#15772) 2023-06-12 12:05:11 -07:00
inference-session.ts [js/rn] Add executionProviders support (#16233) 2023-06-16 19:38:41 +10:00
onnx-value.ts [js/common] allow import onnxruntime-common as ESM and CJS (#15772) 2023-06-12 12:05:11 -07:00
tensor-conversion-impl.ts [js/common] allow import onnxruntime-common as ESM and CJS (#15772) 2023-06-12 12:05:11 -07:00
tensor-conversion.ts [js/common] allow import onnxruntime-common as ESM and CJS (#15772) 2023-06-12 12:05:11 -07:00
tensor-factory-impl.ts [JS/Common] Fix malformed result of Tensor.fromImage(ImageBitmap) (#16919) 2023-07-31 18:18:06 -07:00
tensor-factory.ts [js/common] allow import onnxruntime-common as ESM and CJS (#15772) 2023-06-12 12:05:11 -07:00
tensor-impl.ts [js/common] allow creating (u)int64 tensors in 2 ways (#16541) 2023-07-11 21:07:36 -07:00
tensor-utils-impl.ts [js/common] allow import onnxruntime-common as ESM and CJS (#15772) 2023-06-12 12:05:11 -07:00
tensor-utils.ts [js/common] allow import onnxruntime-common as ESM and CJS (#15772) 2023-06-12 12:05:11 -07:00
tensor.ts [js/common] allow creating (u)int64 tensors in 2 ways (#16541) 2023-07-11 21:07:36 -07:00
version.ts [js] add API that allows to get package version (#16207) 2023-06-09 16:18:53 -07:00