diff --git a/jobs/avatars/AvatarOriginalFileOutput.go b/jobs/avatars/AvatarOriginalFileOutput.go index 00cb50fd..6e1420eb 100644 --- a/jobs/avatars/AvatarOriginalFileOutput.go +++ b/jobs/avatars/AvatarOriginalFileOutput.go @@ -8,7 +8,6 @@ import ( "image/png" "io/ioutil" - "github.com/animenotifier/arn" "github.com/nfnt/resize" ) @@ -39,7 +38,15 @@ func (output *AvatarOriginalFileOutput) SaveAvatar(avatar *Avatar) error { img := avatar.Image 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(uint(output.Size), 0, img, interpolation) buffer := new(bytes.Buffer) var err error diff --git a/jobs/avatars/AvatarWebPFileOutput.go b/jobs/avatars/AvatarWebPFileOutput.go index bc48c05f..fb506b03 100644 --- a/jobs/avatars/AvatarWebPFileOutput.go +++ b/jobs/avatars/AvatarWebPFileOutput.go @@ -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 diff --git a/jobs/avatars/main.go b/jobs/avatars/main.go index d2aa0c76..b4834df1 100644 --- a/jobs/avatars/main.go +++ b/jobs/avatars/main.go @@ -31,10 +31,10 @@ func main() { avatarSources = []AvatarSource{ &Gravatar{ Rating: "pg", - RequestLimiter: time.NewTicker(250 * time.Millisecond), + RequestLimiter: time.NewTicker(150 * time.Millisecond), }, &MyAnimeList{ - RequestLimiter: time.NewTicker(500 * time.Millisecond), + RequestLimiter: time.NewTicker(150 * time.Millisecond), }, }