From 648f333850163efeac486c4b07eb47da415a9c98 Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Thu, 29 Jun 2017 22:39:57 +0800 Subject: [PLT-6496] Remove System Console and config settings for image height and width (#6688) * remove System Console and config settings for image height and width * add constants and update config.json * updated as per review --- app/user.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'app/user.go') diff --git a/app/user.go b/app/user.go index de5881d00..eaeed53a5 100644 --- a/app/user.go +++ b/app/user.go @@ -31,10 +31,11 @@ import ( ) const ( - TOKEN_TYPE_PASSWORD_RECOVERY = "password_recovery" - TOKEN_TYPE_VERIFY_EMAIL = "verify_email" - PASSWORD_RECOVER_EXPIRY_TIME = 1000 * 60 * 60 // 1 hour - VERIFY_EMAIL_EXPIRY_TIME = 1000 * 60 * 60 // 1 hour + TOKEN_TYPE_PASSWORD_RECOVERY = "password_recovery" + TOKEN_TYPE_VERIFY_EMAIL = "verify_email" + PASSWORD_RECOVER_EXPIRY_TIME = 1000 * 60 * 60 // 1 hour + VERIFY_EMAIL_EXPIRY_TIME = 1000 * 60 * 60 // 1 hour + IMAGE_PROFILE_PIXEL_DIMENSION = 128 ) func CreateUserWithHash(user *model.User, hash string, data string) (*model.User, *model.AppError) { @@ -717,13 +718,11 @@ func CreateProfileImage(username string, userId string) ([]byte, *model.AppError return nil, model.NewLocAppError("CreateProfileImage", "api.user.create_profile_image.default_font.app_error", nil, err.Error()) } - width := int(utils.Cfg.FileSettings.ProfileWidth) - height := int(utils.Cfg.FileSettings.ProfileHeight) color := colors[int64(seed)%int64(len(colors))] - dstImg := image.NewRGBA(image.Rect(0, 0, width, height)) + dstImg := image.NewRGBA(image.Rect(0, 0, IMAGE_PROFILE_PIXEL_DIMENSION, IMAGE_PROFILE_PIXEL_DIMENSION)) srcImg := image.White draw.Draw(dstImg, dstImg.Bounds(), &image.Uniform{color}, image.ZP, draw.Src) - size := float64((width + height) / 4) + size := float64(IMAGE_PROFILE_PIXEL_DIMENSION / 2) c := freetype.NewContext() c.SetFont(font) @@ -732,7 +731,7 @@ func CreateProfileImage(username string, userId string) ([]byte, *model.AppError c.SetDst(dstImg) c.SetSrc(srcImg) - pt := freetype.Pt(width/6, height*2/3) + pt := freetype.Pt(IMAGE_PROFILE_PIXEL_DIMENSION/6, IMAGE_PROFILE_PIXEL_DIMENSION*2/3) _, err = c.DrawString(initial, pt) if err != nil { return nil, model.NewLocAppError("CreateProfileImage", "api.user.create_profile_image.initial.app_error", nil, err.Error()) @@ -809,7 +808,8 @@ func SetProfileImage(userId string, imageData *multipart.FileHeader) *model.AppE img = makeImageUpright(img, orientation) // Scale profile image - img = imaging.Fill(img, utils.Cfg.FileSettings.ProfileWidth, utils.Cfg.FileSettings.ProfileHeight, imaging.Center, imaging.Lanczos) + profileWidthAndHeight := 128 + img = imaging.Fill(img, profileWidthAndHeight, profileWidthAndHeight, imaging.Center, imaging.Lanczos) buf := new(bytes.Buffer) err = png.Encode(buf, img) -- cgit v1.2.3-1-g7c22