Detect the generic, auto-generated avatars providers hand out when someone never set a profile picture: Google's letter-on-a-colour, flat solid-colour blocks, the Gravatar mystery-person silhouette, GitHub and Gravatar identicons. It reads the image pixels directly, so you can catch a default and replace it with something of your own.
Try it: avatarsniff.tunc.co
npm install avatarsniff
pnpm add avatarsniff
yarn add avatarsniffimport { sniff } from "avatarsniff";
const result = await sniff(bytesOrUrl);
if (result?.isDefault) {
// a generic provider default; result.matched says which kind
}The full API, the decoding matrix, and the opt-in WEBP/SVG subpaths are in
lib/README.md.
lib/is theavatarsniffpackage: framework- and runtime-agnostic, zero install dependencies.site/is the live demo, a small Next.js app.
pnpm install
pnpm --filter avatarsniff typecheck
pnpm --filter avatarsniff test
pnpm --filter avatarsniff buildMIT © Tunç Türkmen