New image resize algo

This commit is contained in:
Eduard Urbach 2017-11-11 23:19:31 +01:00
parent f3d493f7aa
commit 8860ece340
5 changed files with 38 additions and 27 deletions

View File

@ -65,12 +65,14 @@ func work(anime *arn.Anime) error {
medium := path.Join(os.Getenv("GOPATH"), "/src/github.com/animenotifier/notify.moe/images/anime/medium/") medium := path.Join(os.Getenv("GOPATH"), "/src/github.com/animenotifier/notify.moe/images/anime/medium/")
small := path.Join(os.Getenv("GOPATH"), "/src/github.com/animenotifier/notify.moe/images/anime/small/") small := path.Join(os.Getenv("GOPATH"), "/src/github.com/animenotifier/notify.moe/images/anime/small/")
largeSize := 250 largeSizeX := 250
mediumSize := 142 largeSizeY := 0
smallSize := 55
mediumSizeBonusLowDPI := 8 mediumSizeX := 142
smallSizeBonusLowDPI := 5 mediumSizeY := 200
smallSizeX := 55
smallSizeY := 78
webpQuality := 70 webpQuality := 70
jpegQuality := 70 jpegQuality := 70
@ -119,26 +121,30 @@ func work(anime *arn.Anime) error {
&outputs.ImageFile{ &outputs.ImageFile{
Directory: large, Directory: large,
BaseName: anime.ID, BaseName: anime.ID,
Size: largeSize, Width: largeSizeX,
Height: largeSizeY,
Quality: jpegQuality + qualityBonusLowDPI, Quality: jpegQuality + qualityBonusLowDPI,
}, },
&outputs.ImageFile{ &outputs.ImageFile{
Directory: large, Directory: large,
BaseName: anime.ID + "@2", BaseName: anime.ID + "@2",
Size: largeSize * 2, Width: largeSizeX * 2,
Height: largeSizeY * 2,
Quality: jpegQuality, Quality: jpegQuality,
}, },
&outputs.ImageFile{ &outputs.ImageFile{
Directory: large, Directory: large,
BaseName: anime.ID, BaseName: anime.ID,
Size: largeSize, Width: largeSizeX,
Height: largeSizeY,
Format: "webp", Format: "webp",
Quality: webpQuality + qualityBonusLowDPI, Quality: webpQuality + qualityBonusLowDPI,
}, },
&outputs.ImageFile{ &outputs.ImageFile{
Directory: large, Directory: large,
BaseName: anime.ID + "@2", BaseName: anime.ID + "@2",
Size: largeSize * 2, Width: largeSizeX * 2,
Height: largeSizeY * 2,
Format: "webp", Format: "webp",
Quality: webpQuality, Quality: webpQuality,
}, },
@ -147,26 +153,30 @@ func work(anime *arn.Anime) error {
&outputs.ImageFile{ &outputs.ImageFile{
Directory: medium, Directory: medium,
BaseName: anime.ID, BaseName: anime.ID,
Size: mediumSize + mediumSizeBonusLowDPI, Width: mediumSizeX,
Height: mediumSizeY,
Quality: jpegQuality + qualityBonusLowDPI + qualityBonusMedium, Quality: jpegQuality + qualityBonusLowDPI + qualityBonusMedium,
}, },
&outputs.ImageFile{ &outputs.ImageFile{
Directory: medium, Directory: medium,
BaseName: anime.ID + "@2", BaseName: anime.ID + "@2",
Size: mediumSize * 2, Width: mediumSizeX * 2,
Height: mediumSizeY * 2,
Quality: jpegQuality, Quality: jpegQuality,
}, },
&outputs.ImageFile{ &outputs.ImageFile{
Directory: medium, Directory: medium,
BaseName: anime.ID, BaseName: anime.ID,
Size: mediumSize + mediumSizeBonusLowDPI, Width: mediumSizeX,
Height: mediumSizeY,
Format: "webp", Format: "webp",
Quality: webpQuality + qualityBonusLowDPI + qualityBonusMedium, Quality: webpQuality + qualityBonusLowDPI + qualityBonusMedium,
}, },
&outputs.ImageFile{ &outputs.ImageFile{
Directory: medium, Directory: medium,
BaseName: anime.ID + "@2", BaseName: anime.ID + "@2",
Size: mediumSize * 2, Width: mediumSizeX * 2,
Height: mediumSizeY * 2,
Format: "webp", Format: "webp",
Quality: webpQuality, Quality: webpQuality,
}, },
@ -175,26 +185,30 @@ func work(anime *arn.Anime) error {
&outputs.ImageFile{ &outputs.ImageFile{
Directory: small, Directory: small,
BaseName: anime.ID, BaseName: anime.ID,
Size: smallSize + smallSizeBonusLowDPI, Width: smallSizeX,
Height: smallSizeY,
Quality: jpegQuality + qualityBonusLowDPI + qualityBonusSmall, Quality: jpegQuality + qualityBonusLowDPI + qualityBonusSmall,
}, },
&outputs.ImageFile{ &outputs.ImageFile{
Directory: small, Directory: small,
BaseName: anime.ID + "@2", BaseName: anime.ID + "@2",
Size: smallSize * 2, Width: smallSizeX * 2,
Height: smallSizeY * 2,
Quality: jpegQuality, Quality: jpegQuality,
}, },
&outputs.ImageFile{ &outputs.ImageFile{
Directory: small, Directory: small,
BaseName: anime.ID, BaseName: anime.ID,
Size: smallSize + smallSizeBonusLowDPI, Width: smallSizeX,
Height: smallSizeY,
Format: "webp", Format: "webp",
Quality: webpQuality + qualityBonusLowDPI + qualityBonusSmall, Quality: webpQuality + qualityBonusLowDPI + qualityBonusSmall,
}, },
&outputs.ImageFile{ &outputs.ImageFile{
Directory: small, Directory: small,
BaseName: anime.ID + "@2", BaseName: anime.ID + "@2",
Size: smallSize * 2, Width: smallSizeX * 2,
Height: smallSizeY * 2,
Format: "webp", Format: "webp",
Quality: webpQuality, Quality: webpQuality,
}, },

View File

@ -109,7 +109,6 @@
margin-top 0.5rem margin-top 0.5rem
.anime-cover-image .anime-cover-image
// width 142px
width 250px width 250px
height auto height auto
border-radius 3px border-radius 3px

View File

@ -35,7 +35,7 @@
.sound-track-anime-image .sound-track-anime-image
width 142px width 142px
height 201px height 200px
.music-buttons .music-buttons
display flex display flex

View File

@ -3,7 +3,7 @@
.anime-grid-cell .anime-grid-cell
grid-cell grid-cell
scale-up saturate-up
shadow-up shadow-up
.anime-grid-image .anime-grid-image

View File

@ -6,15 +6,13 @@ mixin grid-cell
position relative position relative
width 142px width 142px
height 16vw height 200px
min-width 90px // min-width 90px
min-height 127px // min-height 127px
max-width 142px
max-height 201px
border-radius 3px border-radius 3px
background-size cover // background-size cover
background-position 50% 50% // background-position 50% 50%
margin 0.5rem margin 0.5rem