From 8deecc33b52af712444a717816a89aac9df2dc35 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sat, 20 Feb 2021 21:12:33 -0500 Subject: [PATCH] exception handling --- src/dom/imageToSquare.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dom/imageToSquare.ts b/src/dom/imageToSquare.ts index d0fcfbf..bba1c82 100644 --- a/src/dom/imageToSquare.ts +++ b/src/dom/imageToSquare.ts @@ -10,6 +10,7 @@ export function imageToSquare(input: HTMLImageElement | HTMLCanvasElement, input throw new Error('imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement'); } + if (inputSize <= 0) return createCanvas({ width: 1, height: 1 }); const dims = getMediaDimensions(input); const scale = inputSize / Math.max(dims.height, dims.width); const width = scale * dims.width;