ksz2k / letter_avatar Goto Github PK
View Code? Open in Web Editor NEWRuby gem for creating letter avatar from user's name (or any other string :-) ).
License: GNU General Public License v2.0
Ruby gem for creating letter avatar from user's name (or any other string :-) ).
License: GNU General Public License v2.0
with ImageMagick 6.8.9-9 Q16 x86_64 2017-07-31, ubuntu 16.04.3 LTS
letter_avatar/lib/letter_avatar/avatar.rb
Line 64 in 3ae1ad9
but after
letter_avatar/lib/letter_avatar.rb
Line 19 in 3ae1ad9
with imagemagick: stable 7.0.7-28, macOS 10.13.3, LetterAvatar.resize
d files reminded under 10kb.
So I think it may be an issue with ImageMagick.
I'm not very good at English so sorry if there are any English syntax error.
I saw the main feature just execute ImageMagick convert
to generate image.
But in README file you said:
sudo apt-get install -y advancecomp gifsicle jhead jpegoptim libjpeg-progs optipng pngcrush pngquant
The install way looks like tooooo hard.
If you remove ImageOptim, it will easily.
Hi @ksz2k, thanks for your share first. when i try it , i meet a problem about utf-8 character generating.
Test Case: LetterAvatar.generate "宋佳洋", 200
Result:
Does it really support or my ImageMagic version problem?
Version: ImageMagick 6.8.9-7
Howdy
I am using Rails 5.0.4
LetterAvatar.generate 'ksz2k', 200
is working just fine. (This is what I get in the rails console)
[2] pry(main)> LetterAvatar.generate 'ksz2k', 200
=> "public/system/lets/letter_avatars/2/K/87_178_230/200.png"
However when trying to use the HasAvatar helper I get the following error
[4] pry(main)> LetterAvatar::HasAvatar
NameError: uninitialized constant LetterAvatar::HasAvatar
Any ideas on what could be going on here?
Since I would like to avoid the dependency on AS, let's rewrite the code to not depend on AS.
> require 'letter_avatar'
NoMethodError: undefined method `mattr_accessor' for LetterAvatar:Module
from /home/vagrant/.gem/ruby/gems/letter_avatar-0.1.7/lib/letter_avatar.rb:7:in `<module:LetterAvatar>'
from /home/vagrant/.gem/ruby/gems/letter_avatar-0.1.7/lib/letter_avatar.rb:5:in `<top (required)>'
from (irb):2:in `require'
from (irb):2
from /usr/bin/irb:11:in `<main>'
This is my initializer:
LetterAvatar.setup do |config|
config.fill_color = 'rgba(255, 255, 255, 0.65)' # default is 'rgba(255, 255, 255, 0.65)'
config.cache_base_path = 'public/system/ava' # default is 'public/system'
config.colors_palette = :iwanthue # default is :google
config.weight = 96 # default is 300
config.annotate_position = '-0+5' # default is -0+5
config.letters_count = 2 # default is 1
config.pointsize = 140 # default is 140
end
And this is how I generate avatar:
LetterAvatar.generate name, 96
And this is the result for dev
and prod
:
I have no idea whey production makes letters almost invisible and tiny. Any idea?
Update:
If I gave weight 500
and pointsize 200
this happens in dev
and prod
:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.