/
plugin.rb
35 lines (29 loc) · 912 Bytes
/
plugin.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# name: mozilla-letter-avatar
# about: Changes letter avatars to be more Mozilla
# version: 0.0.1
# authors: Leo McArdle
# url: https://github.com/mozilla/discourse-mozilla-letter-avatar
after_initialize do
class ::LetterAvatar
VERSION = "#{VERSION}_MOZILLA_1"
def self.generate_fullsize(identity)
color = identity.color
letter = identity.letter
filename = fullsize_path(identity)
instructions = %W{
-size #{FULLSIZE}x#{FULLSIZE}
xc:#{to_rgb(color)}
-pointsize #{POINTSIZE}
-fill #ffffff
-font #{File.expand_path("../zilla-slab/ttf/ZillaSlab-Bold.ttf", __FILE__)}
-gravity Center
-annotate -0+0 #{letter}
-depth 8
#{filename}
}
Discourse::Utils.execute_command('convert', *instructions)
## do not optimize image, it will end up larger than original
filename
end
end
end