diff options
author | Corey Hulen <corey@hulen.com> | 2015-06-22 11:42:54 -0800 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-06-22 11:42:54 -0800 |
commit | b4ae75b944e30489528d617442aee384ec4e4627 (patch) | |
tree | c854c9ca1742bfd6e8eefd74a9a2eaaef3967277 /api | |
parent | 029c3318b678f46d3eceaa9808022bc843c77610 (diff) | |
parent | 2877d691431eacbcd7f3bb2f9c8b94486e8e4c3f (diff) | |
download | chat-b4ae75b944e30489528d617442aee384ec4e4627.tar.gz chat-b4ae75b944e30489528d617442aee384ec4e4627.tar.bz2 chat-b4ae75b944e30489528d617442aee384ec4e4627.zip |
Merge pull request #50 from mattermost/mm-1320
HELIUM fixes mm-1320 removes freetype libs and only use solid color for geneā¦
Diffstat (limited to 'api')
-rw-r--r-- | api/user.go | 39 |
1 files changed, 5 insertions, 34 deletions
diff --git a/api/user.go b/api/user.go index 6af737df3..79d4bb32c 100644 --- a/api/user.go +++ b/api/user.go @@ -5,7 +5,6 @@ package api import ( "bytes" - "code.google.com/p/draw2d/draw2d" l4g "code.google.com/p/log4go" "fmt" "github.com/goamz/goamz/aws" @@ -19,6 +18,7 @@ import ( "hash/fnv" "image" "image/color" + "image/draw" _ "image/gif" _ "image/jpeg" "image/png" @@ -602,42 +602,13 @@ 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] - } - - draw2d.SetFontFolder(utils.FindDir("web/static/fonts")) - i := image.NewRGBA(image.Rect(0, 0, 128, 128)) - gc := draw2d.NewGraphicContext(i) - draw2d.Rect(gc, 0, 0, 128, 128) - gc.SetFillColor(colors[int(seed)%len(colors)]) - gc.Fill() - gc.SetFontSize(50) - gc.SetFontData(draw2d.FontData{"luxi", draw2d.FontFamilyMono, draw2d.FontStyleBold | draw2d.FontStyleItalic}) - left, top, right, bottom := gc.GetStringBounds("CH") - width := (128 - (right - left + 10)) / 2 - height := (128 - (top - bottom + 6)) / 2 - gc.Translate(width, height) - gc.SetFillColor(image.White) - gc.FillString(initials) + color := colors[int(seed)%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) buf := new(bytes.Buffer) - if imgErr := png.Encode(buf, i); imgErr != nil { + if imgErr := png.Encode(buf, img); imgErr != nil { return nil, model.NewAppError("getProfileImage", "Could not encode default profile image", imgErr.Error()) } else { return buf.Bytes(), nil |