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:
co-authored by
coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
parent
ffac812273
commit
6bf2c9983a
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user