How does discourse generate its default avatars?

(Joe Dallago) #1

I’m looking into different options for generating unique avatars, and I’m curious as to how discourse generates the letter avatars.

(Robin Ward) #2

Most of the magic happens in this file:

(Joe Dallago) #3

Awesome, I think I’m getting the gist of it. The one big question I have is what happens with this call discourse/letter_avatar.rb at master · discourse/discourse · GitHub. I’m not terribly familiar with Ruby, so if you could dumb it down a bit.

(Ben T) #4

%w{} becomes an array of strings, and the join method is called to convert it to a space separated string. These instructions are wrapped in backticks. The convert application is called with the arguments from the instructions array. Remember that "#{object}" is an in-string replacement; where the object in question will be converted to a string.

(Jens Maier) #5

convert is documented here: Command-line Tools: Convert @ ImageMagick

It’s a native program and part of the ImageMagick set of image manipulation tools. IM gets installed by the Ubuntu package manager inside the docker container; it’s not part of Discourse.

(Joe Dallago) #6

@trident @elberet awesome thanks guys!