From 09740130e874560957b154bbb51ae4c90dcd64ca Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 29 Nov 2022 11:32:44 -0800 Subject: [PATCH] Use naturalWidth and naturalHeight for image data PiperOrigin-RevId: 491694147 --- mediapipe/web/graph_runner/graph_runner.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mediapipe/web/graph_runner/graph_runner.ts b/mediapipe/web/graph_runner/graph_runner.ts index 9a0f7148..9a810165 100644 --- a/mediapipe/web/graph_runner/graph_runner.ts +++ b/mediapipe/web/graph_runner/graph_runner.ts @@ -325,6 +325,10 @@ export class GraphRunner { if ((imageSource as HTMLVideoElement).videoWidth) { width = (imageSource as HTMLVideoElement).videoWidth; height = (imageSource as HTMLVideoElement).videoHeight; + } else if ((imageSource as HTMLImageElement).naturalWidth) { + // TODO: Ensure this works with SVG images + width = (imageSource as HTMLImageElement).naturalWidth; + height = (imageSource as HTMLImageElement).naturalHeight; } else { width = imageSource.width; height = imageSource.height;