Update js/desktop/src/lib/avatar-image.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Arjun Patel
2026-06-11 15:16:13 -07:00
committed by GitHub
parent ffac812273
commit 6bf2c9983a
+3
View File
@@ -10,6 +10,9 @@ export async function toAvatarBlob(
source: ImageBitmap, source: ImageBitmap,
{ size = 512, mirror = false }: { size?: number; mirror?: boolean } = {}, { size = 512, mirror = false }: { size?: number; mirror?: boolean } = {},
): Promise<Blob> { ): Promise<Blob> {
if (!Number.isInteger(size) || size <= 0) {
throw new Error('Avatar size must be a positive integer');
}
const side = Math.min(source.width, source.height); const side = Math.min(source.width, source.height);
if (side === 0) { if (side === 0) {
// A not-yet-decoded <video> or a corrupt image yields a zero-size source; // A not-yet-decoded <video> or a corrupt image yields a zero-size source;