Skip to content

tunctn/avatarsniff

Repository files navigation

avatarsniff — Sniff out generic default avatars, straight from the pixels.

avatarsniff

npm version bundle size zero dependencies types included license

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

Install

npm  install avatarsniff
pnpm add     avatarsniff
yarn add     avatarsniff
import { 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.

What's in here

Develop

pnpm install

pnpm --filter avatarsniff typecheck
pnpm --filter avatarsniff test
pnpm --filter avatarsniff build

License

MIT © Tunç Türkmen

About

Detect generic/default provider avatars (initials, identicons, Gravatar mystery-person) straight from image pixels. Zero dependencies.

Topics

Resources

License

Stars

Watchers

Forks

Contributors