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 installOr install it yourself with:
gem install nameplateUsage
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
endAsync Generation
For heavy workloads (e.g., pre-warming caches):
future = NamePlate::Avatar::Generator.async_call("Tony", 128)
future.value! # blocks until doneDevelopment
Clone the repo and run:
bin/setup
bundle exec rake specRoadmap
- 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.