Change thumbnail default size and resize algorithm (#336)

* Change thumbnail resize algorithm and add size parameter

* Height -> Width

* Change default size from 100px to 200px

* Height -> width
This commit is contained in:
InfiniteTF
2020-01-31 23:19:15 +01:00
committed by GitHub
parent 03c07a429d
commit 6a6e8d8875
10 changed files with 30 additions and 21 deletions

View File

@@ -52,13 +52,13 @@ func (g *Gallery) GetImage(index int) []byte {
return data
}
func (g *Gallery) GetThumbnail(index int) []byte {
func (g *Gallery) GetThumbnail(index int, width int) []byte {
data, _ := g.readZipFile(index)
srcImage, _, err := image.Decode(bytes.NewReader(data))
if err != nil {
return data
}
resizedImage := imaging.Resize(srcImage, 100, 0, imaging.NearestNeighbor)
resizedImage := imaging.Resize(srcImage, width, 0, imaging.Box)
buf := new(bytes.Buffer)
err = jpeg.Encode(buf, resizedImage, nil)
if err != nil {