getImageDimension function
Gets the width and height from image
(CanvasImageSource).
Implementation
Rectangle<int>? getImageDimension(CanvasImageSource image) {
if (image.isA<HTMLImageElement>()) {
final img = image as HTMLImageElement;
return Rectangle(0, 0, img.naturalWidth, img.naturalHeight);
} else if (image.isA<HTMLCanvasElement>()) {
final canvas = image as HTMLCanvasElement;
return Rectangle(0, 0, canvas.width, canvas.height);
} else if (image.isA<HTMLVideoElement>()) {
final video = image as HTMLVideoElement;
return Rectangle(0, 0, video.width, video.height);
}
return null;
}