Use naturalWidth and naturalHeight for image data

PiperOrigin-RevId: 491694147
This commit is contained in:
Sebastian Schmidt 2022-11-29 11:32:44 -08:00 committed by Copybara-Service
parent c8a413bb4e
commit 09740130e8

View File

@ -325,6 +325,10 @@ export class GraphRunner {
if ((imageSource as HTMLVideoElement).videoWidth) { if ((imageSource as HTMLVideoElement).videoWidth) {
width = (imageSource as HTMLVideoElement).videoWidth; width = (imageSource as HTMLVideoElement).videoWidth;
height = (imageSource as HTMLVideoElement).videoHeight; 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 { } else {
width = imageSource.width; width = imageSource.width;
height = imageSource.height; height = imageSource.height;