From 3c1eefe984cb023402a1e9596de12a1ce7b0dcc3 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Wed, 22 Jul 2015 18:53:28 -0700 Subject: Initial changes to putting initials on default profile pics --- api/user.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'api/user.go') diff --git a/api/user.go b/api/user.go index e1d5e83dd..2dcb1700b 100644 --- a/api/user.go +++ b/api/user.go @@ -623,6 +623,24 @@ func createProfileImage(username string, userId string) ([]byte, *model.AppError h.Write([]byte(userId)) seed := h.Sum32() + initials := "" + parts := strings.Split(username, " ") + + for _, v := range parts { + + if len(v) > 0 { + initials += string(strings.ToUpper(v)[0]) + } + } + + if len(initials) == 0 { + initials = "^" + } + + if len(initials) > 2 { + initials = initials[0:2] + } + color := colors[int64(seed)%int64(len(colors))] img := image.NewRGBA(image.Rect(0, 0, int(utils.Cfg.ImageSettings.ProfileWidth), int(utils.Cfg.ImageSettings.ProfileHeight))) draw.Draw(img, img.Bounds(), &image.Uniform{color}, image.ZP, draw.Src) -- cgit v1.2.3-1-g7c22