Label Images
This gem can be used for generating a default image for a contact to display in your app if you don't have any image of contact.It provides a helper method which will return you a css template of the image.
Installation
Add this line to you Gemfile
and then execute
Or install it yourself using command
Usage
Require the gem
Now you can call the helper method using:
This method takes the following arguments and all parameters are OPTIONAL
first_name ==> Name of the contact. Default value is empty string
last_name ==> This is optional parameter and use it if you need two alphabets to be displayed in the image. Default value is empty string
shape ==> You can set the shape of the image.this parameter takes any of "circle" or "square" as value. Default value is square
radius ==> Set this if you set the shape parameter to circle.this should be specified in pixels. Default value is 40px.
width ==> Set this if you set the shape parameter to square.this should be specified in pixels. Default value is 80px.
bg_color ==> You can set the background color of the image. Default value is generated randomly from few available color codes.
font_size ==> You can set the font size of the alphabet to be displayed in the image. this should be specified in pixels. Default value is 20px.
font_family ==> You can set the font family of the alphabet to be displayed in the image. Default font family is verdana.
font_color ==> You can set the font color of the alphabet to be displayed in the image. Default font color is white.
Example usage:
require 'label_images'
generate_image(first_name:"john", last_name:"peter", shape:"circle", radius:60, font_size:20).html_safe
output screenshot: