Socket
Book a DemoInstallSign in
Socket

avatarly

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

avatarly

1.6.1
bundlerRubygems
Version published
Maintainers
2
Created
Source

Demo

avatarly

Gem Version Build Status

avatarly is a simple gem for creating gmail-like user avatars based on user email or any other string passed

inspired and influenced by https://github.com/johnnyhalife/avatar-generator.rb

Demo

http://avatarly.herokuapp.com

Installation

Avatarly requires ImageMagick to be installed.

Gems

The gems are hosted at Rubygems.org. Make sure you're using the latest version of rubygems:

$ gem update --system

Then you can install the gem as follows:

$ gem install avatarly

Bundler

Add to your Gemfile:

gem "avatarly"

and then type:

bundle install

Usage

To generate image please do:

Avatarly.generate_avatar(text, opts={})

the only required parameter is text. Other options that you can pass are:

  • background_color (#AABBCC)
  • font_color (#AABBCC)
  • size (default: 32)
  • font (path to font - e.g. "#{Rails.root}/your_font.ttf")
  • font_size (default: size / 2)
  • vertical_offset (default: 0)
  • format (default: png)
  • lang (language code if unicode aware upcase required - e.g: :tr, default: nil)
  • separator (the custom string or regex used to split text into its initials)

As a result you will get an image blob - rest is up to you, do whatever you want with it.

For instance you can store avatar in directory with images:

  img = Avatarly.generate_avatar(text, opts={})
  File.open('public/images/avatar_name.png', 'wb') do |f|
    f.write img
  end

License

MIT

FAQs

Package last updated on 28 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.