Introduction

edit

Meziantou.Framework.Avatar generates avatars: small SVG or PNG images that show the initials of a name on a colored background. Use them for the users, teams or projects that have no picture.

A round avatar with the initials JD A round avatar with the initials JP A round avatar with the initials OB A round avatar with the Japanese characters 山田

What you can do with it

  • Generate an avatar from a name, as an SVG string you embed in a page or save as a file. See Getting started.
  • Change its appearance: the shape, the size and the palette of colors. See Appearance.
  • Control the initials: the library picks one or two graphemes from the name, or uses the text you give. See Initials.
  • Make it accessible: announce the full name, or hide a decorative avatar from screen readers. See Accessibility.
  • Rely on stable colors: the same name always gets the same color, for a given palette. See Stable colors.
  • Draw it as an image: create the avatar as a vector scene, and draw it as a PNG, WebP or JPEG image. See Image rendering.

Principles

  • Deterministic. The output depends only on the name and the options: no randomness, no state.
  • SVG first. CreateSvg returns an SVG string, drawn by the browser with its bold monospace font. CreateScene returns a vector scene to draw as an image with Meziantou.Framework.Imaging.VectorGraphics.
  • Safe with untrusted names. The output is always well-formed XML, whatever the name contains.

Namespace

The types are in the Meziantou.Framework namespace:

TypeContains
AvatarGeneratorThe CreateSvg and CreateScene methods
AvatarOptionsThe shape, the size, the palette, the initials and the accessibility options
AvatarShapeRound, Square and RoundedSquare
AvatarColorPairA background color and a foreground color

Next steps