Improved avatar downloader

This commit is contained in:
2017-06-13 17:40:29 +02:00
parent 6836fea857
commit e2b87bddd4
3 changed files with 20 additions and 5 deletions

View File

@ -18,7 +18,15 @@ func (output *AvatarWebPFileOutput) SaveAvatar(avatar *Avatar) error {
// Resize if needed
if img.Bounds().Dx() != output.Size {
img = resize.Resize(arn.AvatarSmallSize, 0, img, resize.Lanczos3)
// Use Lanczos interpolation for downscales
interpolation := resize.Lanczos3
// Use Mitchell interpolation for upscales
if output.Size > img.Bounds().Dx() {
interpolation = resize.MitchellNetravali
}
img = resize.Resize(arn.AvatarSmallSize, 0, img, interpolation)
}
// Write to file