From 6aa10bfb6ba826049facc01b80180d773bd0e44d Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 10 Nov 2017 10:29:42 +0100 Subject: [PATCH] Improved quality for low DPI screens --- assets.go | 5 +++++ jobs/anime-images/anime-images.go | 16 ++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/assets.go b/assets.go index f613eb03..5aebc6c3 100644 --- a/assets.go +++ b/assets.go @@ -48,6 +48,11 @@ func configureAssets(app *aero.Application) { return ctx.File("images/brand/" + ctx.Get("file")) }) + // Anime images + app.Get("/images/anime/*file", func(ctx *aero.Context) string { + return ctx.File("images/anime/" + ctx.Get("file")) + }) + // Cover image app.Get("/images/cover/:file", func(ctx *aero.Context) string { file := strings.TrimSuffix(ctx.Get("file"), ".webp") diff --git a/jobs/anime-images/anime-images.go b/jobs/anime-images/anime-images.go index 5ac7f25e..1e184d33 100644 --- a/jobs/anime-images/anime-images.go +++ b/jobs/anime-images/anime-images.go @@ -72,6 +72,10 @@ func work(anime *arn.Anime) error { webpQuality := 70 jpegQuality := 70 + qualityBonusLowDPI := 10 + qualityBonusMedium := 10 + qualityBonusSmall := 10 + kitsuOriginal := fmt.Sprintf("https://media.kitsu.io/anime/poster_images/%s/original", anime.ID) system := ipo.System{ @@ -113,7 +117,7 @@ func work(anime *arn.Anime) error { Directory: large, BaseName: anime.ID, Size: largeSize, - Quality: jpegQuality, + Quality: jpegQuality + qualityBonusLowDPI, }, &outputs.ImageFile{ Directory: large, @@ -126,7 +130,7 @@ func work(anime *arn.Anime) error { BaseName: anime.ID, Size: largeSize, Format: "webp", - Quality: webpQuality, + Quality: webpQuality + qualityBonusLowDPI, }, &outputs.ImageFile{ Directory: large, @@ -141,7 +145,7 @@ func work(anime *arn.Anime) error { Directory: medium, BaseName: anime.ID, Size: mediumSize, - Quality: jpegQuality, + Quality: jpegQuality + qualityBonusLowDPI + qualityBonusMedium, }, &outputs.ImageFile{ Directory: medium, @@ -154,7 +158,7 @@ func work(anime *arn.Anime) error { BaseName: anime.ID, Size: mediumSize, Format: "webp", - Quality: webpQuality, + Quality: webpQuality + qualityBonusLowDPI + qualityBonusMedium, }, &outputs.ImageFile{ Directory: medium, @@ -169,7 +173,7 @@ func work(anime *arn.Anime) error { Directory: small, BaseName: anime.ID, Size: smallSize, - Quality: jpegQuality, + Quality: jpegQuality + qualityBonusLowDPI + qualityBonusSmall, }, &outputs.ImageFile{ Directory: small, @@ -182,7 +186,7 @@ func work(anime *arn.Anime) error { BaseName: anime.ID, Size: smallSize, Format: "webp", - Quality: webpQuality, + Quality: webpQuality + qualityBonusLowDPI + qualityBonusSmall, }, &outputs.ImageFile{ Directory: small,