exception handling

pull/39/head
Vladimir Mandic 2021-02-20 21:12:33 -05:00
parent c34db982bc
commit 8deecc33b5
1 changed files with 1 additions and 0 deletions

View File

@ -10,6 +10,7 @@ export function imageToSquare(input: HTMLImageElement | HTMLCanvasElement, input
throw new Error('imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement'); throw new Error('imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement');
} }
if (inputSize <= 0) return createCanvas({ width: 1, height: 1 });
const dims = getMediaDimensions(input); const dims = getMediaDimensions(input);
const scale = inputSize / Math.max(dims.height, dims.width); const scale = inputSize / Math.max(dims.height, dims.width);
const width = scale * dims.width; const width = scale * dims.width;