Improved avatar downloader
This commit is contained in:
parent
0ee267a692
commit
c0ffa522b9
@ -37,16 +37,8 @@ func (output *AvatarOriginalFileOutput) SaveAvatar(avatar *Avatar) error {
|
||||
data := avatar.Data
|
||||
img := avatar.Image
|
||||
|
||||
if img.Bounds().Dx() != output.Size {
|
||||
// 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(uint(output.Size), 0, img, interpolation)
|
||||
if img.Bounds().Dx() > output.Size {
|
||||
img = resize.Resize(uint(output.Size), 0, img, resize.Lanczos3)
|
||||
buffer := new(bytes.Buffer)
|
||||
|
||||
var err error
|
||||
|
@ -17,16 +17,8 @@ func (output *AvatarWebPFileOutput) SaveAvatar(avatar *Avatar) error {
|
||||
img := avatar.Image
|
||||
|
||||
// Resize if needed
|
||||
if img.Bounds().Dx() != output.Size {
|
||||
// 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)
|
||||
if img.Bounds().Dx() > output.Size {
|
||||
img = resize.Resize(arn.AvatarSmallSize, 0, img, resize.Lanczos3)
|
||||
}
|
||||
|
||||
// Write to file
|
||||
|
Loading…
Reference in New Issue
Block a user