Project

nameplate

0.0
No release in over 3 years
Gem for creating avatars from user's name
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 1.3, >= 1.3.5
 Project Readme

NamePlate

NamePlate is a Ruby gem for generating simple, Google-style avatar images from names or usernames. It’s a modernized successor to letter_avatar, built with maintainability, SOLID design, and Rails-friendly integration in mind.

Think of it as a quick way to give everyone in your app a unique, consistent avatar — without storing profile photos.


Features

  • 🔠 Generates avatars with initials (e.g., Tony Lombardi → TL)
  • 🎨 Deterministic background colors from input strings
  • 📐 Flexible sizing (from tiny icons to large images)
  • 🖼 Transparent padding and proper centering with MiniMagick
  • ⚡ Caching support for faster repeated lookups
  • ✅ Rails helpers for easy view integration
  • 🧪 Fully tested and type-annotated with RBS

Installation

Add this line to your application’s Gemfile:

gem "nameplate"

And then execute:

bundle install

Or install it yourself with:

gem install nameplate

Usage

Quick Start

require "nameplate"

# Generate a 128x128 avatar for "Tony"
path = NamePlate::Avatar::Generator.call("Tony", 128)

# => "tmp/generated/128.png"

With Rails View Helper

<%= nameplate_avatar("Tony", size: 64, class: "avatar") %>

Outputs an <img> tag pointing to the cached avatar file.


Configuration

You can configure fonts, colors, and weights globally:

NamePlate.configure do |config|
  config.font      = Rails.root.join("app/assets/fonts/YourFont.ttf")
  config.weight    = 400
  config.pointsize = 64
end

Async Generation

For heavy workloads (e.g., pre-warming caches):

future = NamePlate::Avatar::Generator.async_call("Tony", 128)
future.value! # blocks until done

Development

Clone the repo and run:

bin/setup
bundle exec rake spec

Roadmap

  • SVG support
  • Rails engine integration (asset pipeline)
  • Configurable color palettes

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/t0nylombardi/nameplate.


License

MIT License. See LICENSE.txt for details.


NamePlate — because every name deserves a face.