feat: avatars for humans #273
@@ -10,6 +10,9 @@ export async function toAvatarBlob(
|
||||
source: ImageBitmap,
|
||||
{ size = 512, mirror = false }: { size?: number; mirror?: boolean } = {},
|
||||
): 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);
|
||||
if (side === 0) {
|
||||
// A not-yet-decoded <video> or a corrupt image yields a zero-size source;
|
||||
|
||||
Reference in New Issue
Block a user
⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
Validate
sizeas a positive integer before creating the canvas.Line 22 depends on
size; invalid values can yield broken avatar output or throw at runtime.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commits
ffac812to6bf2c99